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

Next challenges

Recent achievements

Recognition

  • Give kudos
  • My kudos

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Problem running script via ssh in Pipelines 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 Oct 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
Community showcase
Published in Bitbucket

Powering DevOps with Bitbucket Server & Data Center

Hi everyone, The Cloud team recently announced 12 new DevOps features that help developers ship better code, faster   ! While we’re all excited about the new improvements to Bitbucket ...

1,922 views 0 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you