Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have hudson setup on a CI server, I'm using robocopy to copy files across to a webserver.

I'm having some problems with exit codes. Robocopy reports so many different exit codes for success and failure, hudson doesn't understand them and reports anything other than 0 as a failure.

I though I'd managed to get around this by calling robocopy to do the same job twice. So the first time it does the task and returns a non-zero exit code and the next time it has nothing to copy so returns a 0. This works when I click the build button on Hudson, but not when it's monitoring the git repo for some reason.

So my question is, can I tell hudson about the individual exit codes so that the build succeeds or would I have to create a wrapper around robocopy to provide exit codes that hudson understands?

Cheers

Tom

UPDATE After Peter's answer, I added the following statements at the end of my robocopy script

if ERRORLEVEL 1 set ERRORLEVEL=0
if ERRORLEVEL 2 set ERRORLEVEL=0
if ERRORLEVEL 3 set ERRORLEVEL=0 
if ERRORLEVEL 5 set ERRORLEVEL=0 
if ERRORLEVEL 6 set ERRORLEVEL=0 
if ERRORLEVEL 7 set ERRORLEVEL=0 

As anything below an 8 is considered a success for robocopy, this translates the error codes for hudson and reports a success. I'd imagine I could refactor this at some point.

Thank you for your help Peter!

UPDATE

Re-factored this with Peter's suggestion:

if %ERRORLEVEL% LEQ 7 set ERRORLEVEL=0

share|improve this question

1 Answer 1

up vote 3 down vote accepted

It is fairly easy. You have to translate the error codes for Hudson. I use the following statement after my robocopy

if ERRORLEVEL 1 set ERRORLEVEL=0

I googled for error codes of robocopy and found the following page. You can search the microsoft pages too for the error codes.

http://www.mysidenotes.com/2008/02/15/robocopy-errorlevel-return-codes-found-in-robocopydoc/

share|improve this answer
    
Thanks for your response Peter. Would this work for other error levels too? Could I add a new if statement for each error level? if ERRORLEVEL 1 set ERRORLEVEL=0 if ERRORLEVEL 2 set ERRORLEVEL=0 if ERRORLEVEL 3 set ERRORLEVEL=0 –  Toggo Jul 28 '10 at 13:13
1  
yes it would. Have a look at the link I posted in my answer, that's what they are doing. You can also use operators like IF %ERRORLEVEL% LEQ 2 set ERRORLEVEL=0 have a look at robvanderwoude.com/ntif.php for more compare operators. –  Peter Schuetze Jul 28 '10 at 15:21
    
Brilliant! Thanks again Peter! –  Toggo Jul 28 '10 at 15:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.