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

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


1 badge earned


Participate in fun challenges

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


Gift kudos to your peers

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


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!


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
Community Members
Community Events
Community Groups

Why does Bamboo build system not respect PowerShell return codes?

I am using Bamboo Server 7.2.3.

Whenever I use WINDOWS_POWER_SHELL as the interpreter for scripts that I am running (either in the UI, or in YAML), I do not get a failed job / task when the script fails.

Example YAML (does not fail the build):

- script:
    interpreter: WINDOWS_POWER_SHELL

I would expect the above code to fail the job that is running this script task, but it does not.

The following code, however, DOES fail the build- notice that I am using the native script interpreter, BINSH_OR_CMDEXE.

Example YAML (fails correctly):

- script:
    interpreter: BINSH_OR_CMDEXE

This is pretty annoying, and I am wondering if I am crazy, or if there is a known bug in bamboo that would speak to this, or even hopefully a solution to this problem.

1 answer

1 vote
Eduardo Alvarenga
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Dec 07, 2021

Hey @Aron Weiler

Unfortunately, exit code handling in Powershell is not the most friendly. You'll need to exit with the exit code if it's non zero manually. For example, after each Invoke-Command you could set it up as follows:

Invoke-Command -ScriptBlock {command123 --options --setting 123}
if ($lastexitcode -ne 0) { exit $lastexitcode }

Invoke-Command -ScriptBlock {command123 --options --setting 456}
if ($lastexitcode -ne 0) { exit $lastexitcode }

Because the exit code will change after each command is invoked, you'll need it after each separate command where you could expect a failure that you'd want the build to abort.

Hope this helps. Let us know if you have any questions or concerns.


Eduardo Alvarenga
Atlassian Support APAC

Hey @Eduardo Alvarenga ,


I have tried your solution, but it is not working. The follwing code ist executed in a "test.ps1" file from a YAML spec.


Code 1 - Error by function

function CheckErrorlevel($Scope){
if($lastExitCode -ne "0")
Write-Host "Error: " $Scope " (" $lastExitCode ")"
exit -100
Write-Host $Scope "OK."
Write-Host $lastExitCode


Code 2 - Error direct

exit 2


Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events