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 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?

1 answer

0 votes
Ben
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 19, 2025

Hi Tigran,

Allow me to step in, as I've noticed that you have not received a response from our community as of yet.

To troubleshoot this for you and determine if this is within our scope - we will need access to your Bitbucket Pipelines build environment, including your YAML configuration, build logs and build history.

To do so - we will need you to raise a support ticket using the paid workspace URL for your company workspace:

If you encounter issues raising a ticket - please let me know your timezone and I will raise one on your behalf with the support team that operates within your region.

Cheers!

- Ben (Bitbucket Cloud Support)

Tigran Sahakyan June 20, 2025

Hi Ben.
Thanks for reaching out.

Just near the time you wrote the answer I found solution to the problem.
And it is by prepending  `script -c` to SSH and SCP commands.

--Tigran

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events