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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,459,917
Community Members
 
Community Events
176
Community Groups

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

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

@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.

Cheers.

Update.
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
fi

echo $?

then:

bash -s < test.sh 
> 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.


Cheers

0 votes
Patrik S Atlassian Team 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

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.

thanks

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events