It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Can I tell Bamboo to accept a different return code from a command as a pass?

Jay Barra Jun 13, 2012

I am trying to run a zip command to package up some artifacts as part of a stage and the tool run from CMD returns 1. Bamboo marks the job as failed because it says it was expecting 0 but valid return codes from the zip tool are 1 for success and negative for failures.

4 answers

1 accepted

1 vote
Answer accepted
Patrick Aikens Jun 13, 2012

I'm not sure you can configure Bamboo that way, but what you COULD do is wrap the invocation of that tool in a script (shell, batch file, etc. depending on your OS) and have the script exit with 0 if the tool exits with 1 (and simply exit with the same exit code as the tool otherwise). Have your build execute that script rather than the tool directly. It's a little bit of work (and I DO think Bamboo should let you define what "Success" and "Failure" exit codes are - I have a couple of problem tools that I've had to do this for myself), but it will get around this problem.

Jay Barra Jun 13, 2012

That seems to work, calling 'dir' or 'echo' after the command I want feels a bit silly, but the build passes now.

Patrick Aikens Jun 15, 2012

'exit /b 0' should work too

something like (warning: untested from the top of my head)

REM Do ZIP command
IF %ERRORLEVEL% EQU 1 (EXIT /B 0)
ELSE (EXIT /B %ERRORLEVEL%)
http://ss64.com/nt/exit.html
Gretchen Sep 16, 2013

Patrick's example above shows the link where you can see a more elaborate example of converting multiple return codes but above it looks like part of the code and so I missed it the first time through. http://ss64.com/nt/exit.html. Also see http://ss64.com/nt/robocopy-exit.html has the myriad of exit codes for Robocopy sorted out into success and failure return codes.

0 votes
Gretchen Sep 16, 2013

I agree with Patrick Aikens' answer and just wanted to add another example that I've used extensively. See the robocopy return code problem here: http://ss64.com/nt/robocopy-exit.html There is an elaborate example of exit codes (codes 0-7 are good copies but different variations, Codes 8-16 include failures). And how to convert them to 0 for a valid (successful) return code 0.

0 votes
Kenneth Dickie Jun 29, 2015

For some reason it wasn't good enough to just "exit /b/ 0". It would still flag the step failed. So I had to actually set the %errorlevel% = 0.

"C:\Program Files\PSTools\psexec.exe" \\servername -s -i -d -accepteula C:\path\to\app.exe
if %errorlevel% GTR 2000 (
ECHO Process started successfully on PID: %errorlevel%
SET %errorlevel% = 0
)
exit /b %errorlevel%
Stefan Wendelmann Apr 16, 2019

Change 

SET %errorlevel% = 0

 

To

SET ERRORLEVEL=0

 

To get this solution to work :) 

0 votes
Steven Hawkins Sep 17, 2015

Just started using Bamboo and this is already causing me headaches, so I've raise the following JIRA issue : -

 

https://jira.atlassian.com/browse/BAM-16356

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Next-gen

Introducing subtasks for breaking down work in next-gen projects

Teams break work down in order to help simplify complex tasks. This is often done iteratively, with tasks being broken down into smaller tasks and so on until the work is accurately captured in well-...

8,469 views 26 38
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you