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

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

Jay Barra
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 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 June 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
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 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 June 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
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 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.

1 vote
StevenHawkins September 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

0 votes
Kenneth Dickie June 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 April 16, 2019

Change 

SET %errorlevel% = 0

 

To

SET ERRORLEVEL=0

 

To get this solution to work :) 

0 votes
Gretchen
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 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.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events