Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins Pipeline Jobs, keep them in queue until an executor is free

I have a Jenkins pipeline job, which in turn starts dynamically several other pipeline jobs in parallel. At the moment I have only 1 node to execute these jobs. All of these jobs start immediately. One of them actually does and starts its stage, and the other ones show in the log that they waiting for an executor:

Started by upstream project "parent project" build number 278
originally caused by:
 Started by user user
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] node
Still waiting to schedule task
Waiting for next available executor on win

I'd very much like to change that behavior and have them start when an executor is free. Until then they should stay in the build queue. The reason is that the durations will get shown all wrong, and in the stage view they all start showing "almost complete" when they haven't actually started.

This is the start of the child projects pipeline script, I do require a matching agent immediately:

pipeline {
agent {
    label "win"
}

stages {

    stage('[Jenkins] Setup') {

Is this achievable somehow? Would I need to switch to scripted pipeline maybe?

like image 747
slincke Avatar asked Nov 07 '22 10:11

slincke


1 Answers

You can use throttle concurrent builds plugin and configure the properties "Maximum Total Concurrent Builds" in your job to required number. This way it will prevent the builds from running if it exceeds than the number you configured and you can see the builds in queue.

like image 184
Shweta Avatar answered Nov 15 '22 07:11

Shweta