I have a job defined as a declarative pipeline that gets triggered by a number of different upstream jobs. Depending on which upstream job triggered my job, I don't necessarily need to run all of the stages in my pipeline, so I want to specify a list of triggers for each stage.
I was hoping to use a when
clause and triggeredBy
conditions to determine when each stage runs, but the documentation isn't very detailed:
triggeredBy
Execute the stage when the current build has been triggered by the param given. For example:
when { triggeredBy 'SCMTrigger' }
when { triggeredBy 'TimerTrigger' }
when { triggeredBy 'UpstreamCause' }
when { triggeredBy cause: "UserIdCause", detail: "vlinde" }
Is there an 'UpstreamCause'
equivalent to the example for 'UserIdCause'
that would allow me to specify which upstream cause should trigger a specific stage? If so, what is the exact syntax? Basically I want to do something like:
when {
anyOf {
triggeredBy cause: 'UpstreamCause', detail: 'Job A'
triggeredBy cause: 'UpstreamCause', detail: 'Job C'
}
}
I'm also open to other approaches for accomplishing this.