How to purposely "failed" your Jenkins job ?
Hello Folks,
While working with Jenkins and writing your script in the Jenkins job you will realise your code is giving the error in Jenkins Terminal but it confirms job as Succeeded. π¨
Here. I am helping you out here for such conditions.πππ₯
The first thing you need to understand your logic and when you have to "failed" you job OR in which condition it should failed.π
Below are the small script which help you to understand this concept.
for i in 1 2 3 4 5
do
if [ $i == 3 ]
then
exit 1
else
echo " $i is the lucky number"
fi
done
This is very small shell script and if you paste it in Jenkins job it will always result as failed.
All you need to focus on exit 1.π₯π₯
πexit 1 will fail your job whenever number 3 is in your list.π
Another example ,
for i in 1 2 4 5
do
if [ $i == 3 ]
then
exit 1
else
echo " $i is the lucky number"
fi
done
which will Succeeded you Jenkins Job.
Thats it in this article , Hope this helps you a lot. π·π·
Thank you for reading,,,ππ
Keep Reading....Keep Sharing....π¬ππ
Comments
Post a Comment