How to mark Jenkins builds as SUCCESS only on specific error exit values (other than 0)?

后端 未结 6 1436
遥遥无期
遥遥无期 2021-02-14 03:37

When I run an Execute shell build step to execute a script and that script returns 0, Jenkins flags the build as SUCCESS, oth

6条回答
  •  余生分开走
    2021-02-14 03:48

    robocopy "srcDir" "destDir" /"copyOption" if %ERRORLEVEL% LEQ 2 exit 0
    

    If robocopy exit code is less than or equal to 2 then it will exit successfully.

    Robocopy Exit Codes:

    0×00   0       No errors occurred, and no copying was done.
                   The source and destination directory trees are completely synchronized. 
    
    0×01   1       One or more files were copied successfully (that is, new files have arrived).
    
    0×02   2       Some Extra files or directories were detected. No files were copied
                   Examine the output log for details. 
    
    0×04   4       Some Mismatched files or directories were detected.
                   Examine the output log. Housekeeping might be required.
    
    0×08   8       Some files or directories could not be copied
                   (copy errors occurred and the retry limit was exceeded).
                   Check these errors further.
    
    0×10  16       Serious error. Robocopy did not copy any files.
                   Either a usage error or an error due to insufficient access privileges
                   on the source or destination directories.
    

提交回复
热议问题