0
I am really new to Jenkins and shell scripts, I just want to know if I have a set of commands which are configured in a build, is there any simple way to know if the job failed or the set of commands terminated to due some reason?

For example as under configure job if we have a set of shell commands as below can i embed them in on if statement as below :

if [   ${jenkinsHome}/doThis.sh > andThis.sh
    ${jenkinsHome}/nowDOThis.sh > ${workpsace}/commit.sh
    ${workpsace}/test.sh test
    ]
  then
   echo "build passed"
  else 
    echo "failed"
  fi

Can i do something like the above. please suggest.

Max
  • 5,380
  • 6
  • 42
  • 66
  • 1
    possible duplicate of [How/When does Execute Shell mark a build as failure in Jenkins?](http://stackoverflow.com/questions/22814559/how-when-does-execute-shell-mark-a-build-as-failure-in-jenkins) – Vorsprung Nov 27 '14 at 14:30
  • just set the exit code from the final bit of shell – Vorsprung Nov 27 '14 at 14:31
  • @Vorsprung, How can i do that i am really new to this, Really appreciate if you can guide me – Max Nov 27 '14 at 14:39
  • use echo %errorlevel% in your script to know error code after executing your code (windows, for linux it will be $errorlevel) you can set the same by set errorlevel=0 – prudviraj Dec 04 '14 at 08:04

0 Answers0