Hi Jenkins people,

*TL;DR:* 
is there any way to queue pipeline job if there are no executors available 
on the given node without actually starting a build, like I can do with 
freestyle job and "Restrict where this project can be run" option or 
throttling plugin?


*Long story:*
I have recently ran into the question of queuing Jenkins pipeline jobs. The 
initial case is following:

We have N number of jobs that do some work on available devices. There are 
multiple job per device, while device can handle only one job at a time. 
(it is acceptance testing of SOC's if anyone really interested).
Previously we handled that by using 
https://github.com/jenkinsci/throttle-concurrent-builds-plugin - by 
creating separate category for each device, assign each job with category 
accordingly and limiting number of jobs in category by 1. 

This all works like a charm, but devices can be used by other means beside 
Jenkins - and if for some reason device is NA at the given moment - Jenkins 
has no idea about it. This causes issues on both sides - no other system 
can use device during the jobs execution, while jobs may fail due to 
external problems with device.

So we've decided to merry our device access distribution system API(which 
can tell if device is available atm) with Jenkins, so whenever it says that 
device is NA - Jenkins knows the job should be queued and waits. So I want 
pipeline job to verify device availability before starting the build, and 
if device available - "lock" it and start building, otherwise put build 
into queue. The initial idea was to create abstract node per device, and 
put it online/offline based on device availability calling Jenkins API from 
our device distro system, while restrict job only for that node. In the end 
of the day it looks exactly like throttling plugin, but instead of category 
we have nodes. 

And here comes the problem - in simple job types, like, "freestyle job", 
using option "Restrict where this project can be run" and if there is no 
executors available on the node - there is queue instance created, but no 
build started. In the job view it looks like grey pic with "Planned build 
ID" and explanation that it waits for free executor. And, e.g., if you 
cancel it - no trace is left, it is just removed from queue. 

Same time in pipeline job there is no such setting as "Restrict where this 
project can be run", and even if I use node step as a first thing in 
jenkinsfile like:

node("node_with_no_executors_available") {

    "Hello wold!"

}

build *will *start, build ID will be assigned and Run instance will be 
created. After this, the build will be paused waiting for available 
executor on "node_with_no_executors_available", but the build will be 
marked as RUNNING and will be written to builds history. Cancelling build 
will result in "aborted status" finished build.

So the question is - is there any way to queue pipeline job if there are no 
executors on a given node, without actually starting a build, like I can do 
with freestyle job or throttling plugin?

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/79e700ce-8a90-4546-8fac-9be9ee4bb06a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to