RE: Avoid script shell build failure
Yes you’re right and it avoids if loop. Thank De : jenkinsci-users@googlegroups.com [mailto:jenkinsci-users@googlegroups.com] De la part de JonathanRRogers Envoyé : mercredi 24 juillet 2013 18:55 À : jenkinsci-users@googlegroups.com Cc : dirk.heinri...@recommind.com Objet : Re: Avoid script shell build failure On Wednesday, July 24, 2013 12:53:09 PM UTC-4, JonathanRRogers wrote: On Wednesday, July 24, 2013 5:49:46 AM UTC-4, Dirk Heinrichs wrote: Am Mittwoch, 24. Juli 2013, 11:25:10 schrieb Adrien Ruffié: Do you have an idea, how I can avoid this failure and continu other build step and enter into else statement ? It's because the script is started with -xe. -e lets the script fail as soon as any command exits with non-zero return code. Try adding set +e at the top of your script. I think a better way is to leave the -e as is and deal just with the commands which could fail. For example, the above script might have the git commit line rewritten to allow it to fail without ending the entire script: git commit --verbose -F webapp/res/description.xml true Sorry, I wasn't thinking clearly for a second. The command should be: git commit --verbose -F webapp/res/description.xml || true -- You received this message because you are subscribed to the Google Groups Jenkins Users group. To unsubscribe from this group and stop receiving emails from it, send an email to mailto:jenkinsci-users+unsubscr...@googlegroups.com jenkinsci-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- You received this message because you are subscribed to the Google Groups Jenkins Users group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Avoid script shell build failure
Hello all, Into one job I have the following script shell build step : git status /tmp/git.status grep webapp/res/description.xml /tmp/git.status /dev/null returncode=$? if [ $returncode -eq 0 ]; then git add -- webapp/res/description.xml git commit --verbose -F webapp/res/description.xml echo description.xml modification added and committed else echo No commit found for description.xml fi But when I run the job, if git.status file doesn’t have webapp/res/description.xml string in the file, my job fail and doesn’t enter in the else statement (I think, because echo No commit found for description.xml wasn’t display in Jenkins console) Below log of job: [Release-Job] $ /bin/sh -xe /tmp/hudson7451866342547575378.sh + git status + grep webapp/res/description.xml /tmp/git.status Build step 'Exécuter un script shell' marked build as failure Finished: FAILURE Do you have an idea, how I can avoid this failure and continu other build step and enter into else statement ? Great thank and best regards. Adrien Ruffié -- You received this message because you are subscribed to the Google Groups Jenkins Users group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Avoid script shell build failure
Am Mittwoch, 24. Juli 2013, 11:25:10 schrieb Adrien Ruffié: Do you have an idea, how I can avoid this failure and continu other build step and enter into else statement ? It's because the script is started with -xe. -e lets the script fail as soon as any command exits with non-zero return code. Try adding set +e at the top of your script. HTH... Dirk http://www.recommind.com -- You received this message because you are subscribed to the Google Groups Jenkins Users group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
RE: Avoid script shell build failure
Good explanation here. http://thingsyoudidntknowaboutjenkins.tumblr.com/post/30255425955/why-does-jenkins-think-my-build-succeeded -Original Message- From: jenkinsci-users@googlegroups.com [mailto:jenkinsci-users@googlegroups.com] On Behalf Of Dirk Heinrichs Sent: Wednesday, July 24, 2013 5:50 AM To: jenkinsci-users@googlegroups.com Subject: Re: Avoid script shell build failure Am Mittwoch, 24. Juli 2013, 11:25:10 schrieb Adrien Ruffié: Do you have an idea, how I can avoid this failure and continu other build step and enter into else statement ? It's because the script is started with -xe. -e lets the script fail as soon as any command exits with non-zero return code. Try adding set +e at the top of your script. HTH... Dirk http://www.recommind.com -- You received this message because you are subscribed to the Google Groups Jenkins Users group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- You received this message because you are subscribed to the Google Groups Jenkins Users group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Avoid script shell build failure
On Wednesday, July 24, 2013 5:49:46 AM UTC-4, Dirk Heinrichs wrote: Am Mittwoch, 24. Juli 2013, 11:25:10 schrieb Adrien Ruffié: Do you have an idea, how I can avoid this failure and continu other build step and enter into else statement ? It's because the script is started with -xe. -e lets the script fail as soon as any command exits with non-zero return code. Try adding set +e at the top of your script. I think a better way is to leave the -e as is and deal just with the commands which could fail. For example, the above script might have the git commit line rewritten to allow it to fail without ending the entire script: git commit --verbose -F webapp/res/description.xml true -- You received this message because you are subscribed to the Google Groups Jenkins Users group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Avoid script shell build failure
On Wednesday, July 24, 2013 12:53:09 PM UTC-4, JonathanRRogers wrote: On Wednesday, July 24, 2013 5:49:46 AM UTC-4, Dirk Heinrichs wrote: Am Mittwoch, 24. Juli 2013, 11:25:10 schrieb Adrien Ruffié: Do you have an idea, how I can avoid this failure and continu other build step and enter into else statement ? It's because the script is started with -xe. -e lets the script fail as soon as any command exits with non-zero return code. Try adding set +e at the top of your script. I think a better way is to leave the -e as is and deal just with the commands which could fail. For example, the above script might have the git commit line rewritten to allow it to fail without ending the entire script: git commit --verbose -F webapp/res/description.xml true Sorry, I wasn't thinking clearly for a second. The command should be: git commit --verbose -F webapp/res/description.xml || true -- You received this message because you are subscribed to the Google Groups Jenkins Users group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.