Al-Mothafar
Al-Mothafar

Reputation: 8219

Can I make Atlassian Bamboo to accept a different return code than 0 as success

I have an issue with exciting task with type command that return different exit codes that actually is meaning success , while Atlassian Bamboo is just see 0 as success and anything else as failed.

I'm trying to execute robocopy command which 0 , 1 and 2 meaning (or even in some casses 4) nothing than its success with some notes. See the doc: http://ss64.com/nt/robocopy-exit.html

My example here, tht I have task of type Command execute Robocopy with the following argument:

. c:\inetpub\CIVEBuildCentral\UI\. /IS /S /XD node_modules

How I can make it accept another codes rather than 0 ?

Upvotes: 1

Views: 2411

Answers (1)

Al-Mothafar
Al-Mothafar

Reputation: 8219

I found easy simple solution for this :

I just replaced the task with new task of type Script and Kept Script location as Inline and in the Script Body I did write the following simple codes :

Robocopy . c:\inetpub\CIVEBuildCentral\UI\. /IS /S /XD node_modules 
IF %ERRORLEVEL% LEQ 4 exit /B 0

In this case if exit code was less than or equal 4 I force script to make it return 0 which is success.

You can make more code to handle the another exit codes like REM messages and them make it return 0 or 1 .

Edit: If you using Linux: for handle error codes like this example the if condition will be like:

if [$? le 4]
    then 
    exit 0
fi

Upvotes: 1

Related Questions