Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Problem running script via ssh in Pipelines

Patricio Gayol
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 15, 2019 edited

Hi everyone!

A few days ago, my pipeline (which was working right until then) stopped working. My files are the following:

bitbucket-pipelines.yml

image: atlassian/default-image:2

pipelines:
branches:
develop:
- step:
name: Deploy develop to DigitalOcean.
caches:
- node
deployment: test
script:
  - cat deploy-develop.sh | ssh (Droplet URI)

 devploy-develop.sh

#!/usr/bin/env bash

cd projectFolder
git pull
docker stop projectContainer
docker rm projectContainer
docker tag
docker build --build-arg enviroment=develop -t project .
docker run -d -p 4200:4200 --restart on-failure --name projectContainer project .
docker rmi $(docker images --filter "dangling=true" -q --no-trunc)

 

As I said, it was working perfect for months, but in the last days, every time I run the pipeline, I get the following console output:

+ cat deploy-develop.sh | ssh (DROPLET URI)
Pseudo-terminal will not be allocated because stdin is not a terminal.
Warning: Permanently added the RSA host key for IP address ('IPADDRESS') to the list of known hosts.
Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-142-generic x86_64)
* Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage Get cloud support with Ubuntu Advantage Cloud Guest: http://www.ubuntu.com/business/services/cloud121 packages can be updated.0 updates are security updates.New release '18.04.2 LTS' available.Run 'do-release-upgrade' to upgrade to it.
.-bash: line 3: cd: projectFolder: No such file or directory
git: 'pull' is not a git command. See 'git --help'.Did you mean this? pull
Error response from daemon: No such container: projectContainer

(goes on)

 

Apparently, simple command as "cd" or "git pull" are not working well now.

If I ssh into my droplet and run the script, it works right. The problem appears when the pipelines tries to run it. 

Any ideas?

 

Thank you!

1 answer

0 votes
mkleint
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 21, 2019

that `cd` command failed not because cd is not present on the image, but because `projectFolder` is not a subdirectory of current working directory.

git should be installed on atlassian/default-image:2 as per https://hub.docker.com/r/atlassian/default-image/

 

not sure how `docker stop projectContainer` ever worked given that the container is likely not running or present at the start of the step. Unless you have some additional script entries before the listed shell script.

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, team '25, conference, certifications, bootcamps, training experience, anaheim ca,

Want to make the most of Team ‘25?

Spend the day sharpening your skills in Atlassian Cloud Organization Admin or Jira Administration, then take the exam onsite. Already ready? Take one - or more - of 12 different certification exams while you’re in Anaheim at Team' 25.

Learn more
AUG Leaders

Upcoming Bitbucket Events