First some context:
Currently I have a Jenkins job setup to run a perl script, that in turns builds source code on whatever machine it is running.
From my observation of the Jenkins behaviour, if I abort a running Jenkins job from the UI all the associated threads (single or parallel) of my perl script are killed on the respective slave machine.
Now what I would like to replicate that behaviour ie abort a Jenkins job IF during my build step my script produces some errors. Unfortunately I am not able to easily modify or update the perl script that is being launched (I am not the owner) so I have to find a solution that would need minimal modification the perl script itself, if possible of course.
The reason I need it to be aborted is because we do not want to build any down stream dependencies after the area/repos/location where an error has been produced.
Would I be able to automate this type of behaviour? Maybe by scanning the logs of the perl script in search of error? Or something of the sort?
Any leads would be much appreciated.
Do let me know if more information/clarification is needed.
Thanks.
EDIT:
I found an interesting solution that actually aborts the job. By running the following command:
curl --request POST -u <username>:<password> "%JENKINS_URL%/job/%JOB_NAME%/lastBuild/stop"
Of course, I would now have to figure a way to launch this command whenever any errors are found in the areas that are currently being compiled.
I feel like I am half way though.