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

making bitbucekt pipelines fail on atlassian/ssh-run:0.2.2 pipe errors

Gangadhar Mamillapalli May 9, 2022

When we are using 

atlassian/ssh-run:0.2.2. pipe in our bitbucket pipelines to run some commands like 
==> tsc (type script compilaton in Node Project), if there are some compilation issues, pipielines are still getting passed. 
How to make it fail if there are some compilation issues or GIT issues.

2 answers

0 votes
lissyaka May 20, 2022

@Gangadhar Mamillapalli, @Patrik S hi.
Our team can confirm this pipe have an issue according to: bash over ssh problem

So even if your script fails with exit 1, pipe still be successful.

We will release a new version of pipe, when we will fix this.


lissyaka May 20, 2022

So after some tests executed i cannot confirm the bug exists.
If you provide this in your bash script:

cat non_existent_file

  then the pipe will fail as expected: `Execution failed.`
But if you provide this in your bash script:

cat non_existent_file;echo $? 

then the pipe will end with success status: `Execution finished.` Despite the fact the result of `echo $?` was 1, the status of the last command is 0

cat non_existent_file;echo $? 
> cat: non_existent_file: No such file or directory
> 1
echo $?
> 0

What can help you is manual call of exit 1 if needed if you have multiple commands in your script, something like this

cat non_existent_file;

if [ $? -ne 0 ]; then
exit 1

echo $?


bash -s < 
> cat: non_existent_file: No such file or directory
echo $?
> 1


Problem described in my previous response relates to bash command, not to bash script and was already solved.

We will update the pipe with some additional tests to provide more coverage, but no changes to logic.


0 votes
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 10, 2022

Hello @Gangadhar Mamillapalli ,

Thank you for reaching out to Atlassian Community!

In theory, as long as the commands/scripts you are running in the ssh pipe are returning a non-zero exit code when they fail, the pipe step should fail as well. An exit code is a number returned by the executable to show whether it was successful or not.  The standard for Linux/Unix systems is to return 0 for success and any number from 1 to 255 for anything else.

What might be happening is that, although the command you are executing is failing, it's still returning a 0 (zero) exit code, which for the pipe means successful execution. 

To confirm that you can execute locally the same command/script you are doing in the pipe, and print the value of $? right after it, as $? will contain the exit code of the last executed command. The test would be like the following :

bash <command/script you are runnin in the pipe>; echo $? 

If the command/script fails and still returns an exit code 0, this is the reason why you are seeing the pipe as successful in this case.

Hope that helps. Let me know if you have any questions.

Thank you, @Gangadhar Mamillapalli .

Kind regards,

Patrik S

Gangadhar Mamillapalli May 11, 2022

Thank you @Patrik S  for the hint, its returning non zero value only but some how its not breaking the pipelines, will check more on this and come back.


Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events