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

How to scp and run ssh commands in pipelines?

Mike Hardy February 6, 2018

Hi, I'm trying to setup my pipeline to deploy our repo to Google Compute Engine but I'm facing a few issues.

First, I can SSH in but passing commands using SSH fails.

Second, SCP is failing with the error `No such file or directory`.

This is my pipeline:

 - ssh -i ~/.ssh/config my-bitbucket-username@<IP> 'Gracefully shutdown'
- scp -r -i ~/.ssh/config ~/  my-bitbucket-username@<IP>:~/
- ssh -i ~/.ssh/config my-bitbucket-username@<IP> 'Do a bunch of stuff'

1. The first ssh command fails, but if I don't pass a command,  it succeeds

2. The scp fails with ` No such file or directory`. I've even tried to pass the path that was output from the build setup, `Cloning into '/opt/atlassian/pipelines/agent/build'...`

What am I doing wrong here?

 

1 answer

0 votes
Nova Satori February 9, 2018

1. What you send in as argument to "SSH" needs to be a command. You need a command like:

ssh username@<IP> 'echo "Gracefully shutdown"'

2. Are you trying to copy your entire home directory to the target machine? Usually, you give a name on both source and target:

scp -r ~/mysourcedir username@<IP>:~/mydestinationdir
Mike Hardy February 9, 2018

Thanks for jumping in Nova but I do pass a series of commands. That was just filler text. For anyone that wants to figure it out, read the docs closely. You'll need to pass the bitbucket username to the public key and then copy that to the VM. That's where I went wrong, and it is in the pipelines docs but took a while to spot.

Warre Buysse November 1, 2018

@Mike Hardy would you have an example of this?

Alessandro Benedetti April 1, 2019

Hi Mike, I am struggling in doing the same, I get the "No such file or directory" whatever I do and I pass (relative or absolute path) .
I didn't understand your comment about : "You'll need to pass the bitbucket username to the public key and then copy that to the VM"
Can you elaborate a bit more?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events