Mariano
Mariano

Reputation: 270

Force batchfile to fail in Jenkins

I have a windows batchfile run by Jenkins that check a file, in case that the responce is fail the batchfile must return an error code.

I've tryed to do it in the following way:

findstr /m /c:"FAIL" testJenkins.log
if not errorlevel 1 (
    EXIT /B 1
    echo main batch  FAIL >>testJenkins.log 
) else (
 findstr /m /c:"SKIP" testJenkins.log
 if not errorlevel 1 (
     EXIT /B 1
     echo main batch  SKIP >>testJenkins.log 
 ) else (
     EXIT /B 0 
   echo main batch  PASS >>testJenkins.log 
 )
)

but the result of the Jenkins job is always green.

Upvotes: 0

Views: 1187

Answers (1)

MC ND
MC ND

Reputation: 70943

Your EXIT commands prevent echo lines to execute. First, echo what you need, then exit

Upvotes: 3

Related Questions