I have a Jenkins job, that uses the pipeline mechanics. It has several steps. For understanding let's assume I have 3 stages. the first 2 run in parallel, the 3rd after them. Now depending on the result of the last build of stage 3 I want to do different thing. If stage 3 was previously successful, I want the result from stage 1, otherwise take stage 2 result. Is this possible to check? I don't get how to retrieve the last result of a stage, only did a similiar thing for last state of a job.
currentBuild.rawBuild
global variable, which is available throughout your pipeline. It returns you aRun
object, described here. You may then call smth likecurrentBuild.rawBuild.getPreviousSuccessfulBuild()
and dig into jenkins API in order to somehow retrieve Stage results. Please also make sure, that an access torawBuild
is allowed in your Jenkins groovy sandbox. - Aleks