Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

rsync not finding local directory when sending through SSH on pipeline

Joshua Martin December 13, 2019

Using bitbucket pipelines to push to our remote from the build process that you get from the pipeline.

This is a snippet of the bitbucket-pipelines.yml file

- pipe: atlassian/ssh-run:0.2.2
variables:
SSH_USER: $PRODUCTION_USER
SERVER: $PRODUCTION_SERVER
COMMAND: '''rsync -zrSlh -e "ssh -p 22007" --stats --max-delete=0 $BITBUCKET_CLONE_DIR/ $PRODUCTION_USER@$PRODUCTION_SERVER:home/$PRODUCTION_USER'''
PORT: '22007'

The connection itself works, and it does run the command correctly once it is remoted onto the server...

INFO: Executing the pipe...
INFO: Using default ssh key
INFO: Executing command on {HOST}
ssh -A -tt -i /root/.ssh/pipelines_id -o StrictHostKeyChecking=no -p 22007 {USER}@{HOST} 'rsync -zrSlh -e "ssh -p 22007" --stats --max-delete=0 /opt/atlassian/pipelines/agent/build/ {USER}@{HOST}:home/{USER}'
bash: rsync -zrSlh -e "ssh -p 22007" --stats --max-delete=0 /opt/atlassian/pipelines/agent/build/ {USER}@{HOST}:home/{USER}: No such file or directory
Connection to {HOST} closed.

I've tried to run the same command locally from the directory on my machine

ssh -A -tt -i /root/.ssh/pipelines_id -o StrictHostKeyChecking=no -p 22007 {USER}@{HOST} 'rsync -zrSlh -e "ssh -p 22007" --stats --max-delete=0 "$PWD" {USER}@{HOST}:/home/{USER}'

but it just duplicates the home directory on the remote.

It looks to me like it's looking for the source directory on the server and not looking at the docker container from bitbucket (or the files on my local machine with `pwd`).

If I try to run the command without the '' then it fails because it's using port 22 by default. I've also tried offsetting the command into a bash script and using MODE: 'Script' which is an acceptable pattern for the plugin, but I can't use my environment variables in the sh file.

1 answer

1 accepted

0 votes
Answer accepted
Joshua Martin December 18, 2019

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events