new comer to Jenkins, for context I have a Jenkins set up that has the controller and 4 other nodes. Each node has it's own label(node1-4). Node3 has the label 'failover' and node4 has the label 'failover2'. What I would like to do is when a build is submitted the person submitting the build can set it to run on a specified node ex. node1. It should then try to run on node1 and if that node is unavailable/busy it then tries to run on node3 and if that node is unavailable/busy try node4, otherwise go into the queue and wait for the specified node to be available.
Not sure if this is possible or not but I have something along the lines of the below just before the pipeline starts. Right now this seems to almost act if it was agent any and seems to randomly select a node to build on.
import groovy.transform.Field
@Field
def BUILD_NODE = ""
if (params.DEBUG_JOB == 'true') {
BUILD_NODE = "${params.NODE_LABELS}"
} else {
BUILD_NODE = '${params.NODE_LABELS} || Failover || Failover2'
}
pipeline {
agent {label "${BUILD_NODE}"}