I’ve created a library with a single function, which I’m calling on the first stage of my pipeline.
Depending on it’s processing, this function may abort the pipeline, and that’s my problem.
The function is named “jobCheckup”:
Inside this function, I’m calling:
currentBuild.result = 'ABORTED';
But, although it’s aborting the pipeline, everything below this stage works according the “when”.
I would like to abort the whole pipeline after this call.
Is there a way for it?
I think the easiest way would be to throw an exception, that’ll stop everything as is. Might mark the job as unstable instead of aborted though.
Abort current build from pipeline in Jenkins - Stack Overflow seems to say you should set the result to aborted like you did, then call error()
Hmm, oh yes, I understand.
We have alerts according the stopping reason, so it would not be cool if it display as an error.
Marking as unstable will avoid executing all the below steps?
I don’t know. I recommend trying it out and seeing. The stack overflow seems to say if you set the status then abort you should keep the status.
Tested two approaches and this one works perfectly.
It will stop the whole pipeline process imediatally, finishing it as ABORTED.