Suppose I have two similar simple pipeline scripts, each of which basically look like this:
stage('only stage') {
node {
// first step
}
node {
// second step
}
}
Let's call the steps in my first script A and B, and the steps in my similar second script C and D.
The way I understand it from my testing, as I kick off builds for these scripts, Jenkins appears to queue only the first step from each script, and then queue the next step only when the first one finishes. As a result, it appears to favour earlier running steps in pipelines in general. Consider this example which maps actions I've taken => the resulting Jenkins queue of steps:
Kick off script 1 => [A]
Kick off script 2 => [A, C]
A starts => [C]
A finishes => [C, B]
C starts => [B]
...etc
My question is: at the last step I've depicted where C starts, is there a way to prioritize B to start instead, since it's a later step in a build (vs. C which is a first step)? My motivation is that I would rather have one build completely finished sooner, vs. several builds simultaneously in progress / partially finished.
It seems like this was possible with freestyle projects through the Parameterized Trigger plugin (details in this question), but I haven't been able to figure out if there's a similar way to make this work with pipeline scripts. I've seen the Priority Sorter plugin which apparently has recently added pipeline compatibility, but I didn't understand how that pipeline compatibility actually worked as I was unable to find any examples or documentation on its usage, and I'm not sure hardcoding priority numbers into my steps would be an ideal solution anyway (in reality, the scripts are much more complex than the examples I provided, so I could see priority numbers quickly getting unwieldy and confusing). There are a few other "priority" based plugins I found, notably the Accelerated Build Now plugin, but it hasn't been updated in years so it doesn't have pipeline support.
So far the attitude I've seen is that in situations where queues are forming and prioritization of tasks is needed, "just add more slaves". This makes sense as a design decision, but unfortunately I'm working with limited resources and do need some queue management as I can't just add more slaves to relieve the queue. Has anyone else solved this?