cancel
Showing results for
Did you mean:
See all
See all
##### Top groups
Explore all groups

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

4,295,553
Community Members

Community Events
165
Community Groups

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

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.

#### 1 accepted

1 vote

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.

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

'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

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

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

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%

Change

SET %errorlevel% = 0

To

SET ERRORLEVEL=0

To get this solution to work :)

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.

###### TAGS
Community showcase
Published in Bamboo

### Bamboo Data Center on Kubernetes

Hi, If you are running self-managed environments and looking to adopt modern infrastructure, Bamboo Data Center can now be deployed in a Kubernetes cluster. By leveraging Kubernetes, you can easily...

943 views 3 8

### Community Events

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

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

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