When we are using
@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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.