Configure Node/Job Priority

10 views
Skip to first unread message

Wouter Slob

unread,
Aug 16, 2018, 9:04:50 AM8/16/18
to Jenkins Users
Hi,

I'm working with pipeline jobs where we use different kind of nodes.
The nodes have only one executor each.
I'm trying to find a way to give priority to certain jobs, in such a way that they are executed once a node is available, even though another job already requested to use the node.

To illustrate my case consider a Low Prio Job, with a pipeline like:
def steps = [:]

steps
['s1'] = {
    stage
("LP1") {
        node
("X") {
            println
"Low Prio Job, Step 1"
            sleep
30
       
}
   
}
}
steps
['s2'] = {
    stage
("LP2") {
        node
("X") {
            println
"Low Prio Job, Step 2"
            sleep
30
       
}
   
}
}
parallel steps


And a High Prio Job, with a pipeline like:
def steps = [:]
steps
['s1'] = {
    stage
("HP1") {
        node
("X") {
            println
"High Prio Job, Step 1"
            sleep
30
       
}
   
}
}
steps
['s2'] = {
    stage
("HP2") {
        node
("X") {
            println
"High Prio Job, Step 2"
            sleep
30
       
}
   
}
}
parallel steps

I start the Low Prio Job first and the High Prio Job a couple of seconds later.

What happens is that both stages of the Low Prio Job are executed and then the two stages of the High Prio Job.
So in time over both jobs the output is:
Low Prio Job, Step 1
Low Prio Job, Step 2
High Prio Job, Step 1
High Prio Job, Step 2

I would like to be able to change this behavior such that the High Prio Job gets to use the node as soon as it is available, making the output in time look like:
Low Prio Job, Step 1
High Prio Job, Step 1
High Prio Job, Step 2
Low Prio Job, Step 2

I've tried to use the Priority Sorter Plugin, but it looks like this plugin only impacts the initial start of a build, not during the build.

Does anybody have any suggestions on how to solve this challenge?
Any other plugins I could look into? Or any extension point that could be used to do this?

Thnx!

Reply all
Reply to author
Forward
0 new messages