Forums

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

Asynchronous run of multiple SSH commands in Pipeline's bash script

Tigran Sahakyan
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!
June 17, 2025

I run a self hosted Linux Shell BitBucket Runner and my pipeline's script is a bash script.
It has lots of phases but I'll show a part of it and I'll use short placeholders.
1. Build the project
2. ssh USER@SERVER "@cleanup"

3. scp OUTPUT_ZIP_FILE USER@SERVER:
4. ssh USER@SERVER "unzip ZIP_FILE ; cd FOLDER ; @Build ; zip OUTPUT_ZIP [.FOLDER...]*.*"

5. ssh USER@SERVER "copy [.FOLDER...]*.* [.NEW_FOLDER...]*.* ; @cleanup_foler, zip NEW_PACKAGE.zip [.NEW_FOLDER...]*.*"

The important thing I want is that these steps should run sequentially, the pipeline should wait for each command to finish and then execute the next command.
In the log of the pipeline I see quick dump of these steps and then Success, on remote machine I see CPU usage goes up and it continues doing its job for few minutes, even thought the pipeline is done already.

The bash script does what it should do when run on Linux machine, in a bash shell.

I tried to make each ssh->scp->ssh->ssh phase a step in bitbucket-pipeline.yml file. Step ran sequentially, but, again, each SSH command exits immediately without waiting for the command to finish.

What could be the problem of this "async" run of SSH commands?

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events