Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Job DSL Restrict jobs to selected nodes

I am struggling to restrict Jenkins job to specific nodes using Job DSL plugin.

I tried something like :

job("campaign") {
    parameters {
     stringParam("ARTIFACT_NUMBER", "","")
     nodeParam('TEST_HOST') {
         defaultNodes(["Slave"])
     }
    }
    steps {
        shell('''#!/bin/bash
ARTIFACT_DIR=daily_${ARTIFACT_NUMBER}
echo ${ARTIFACT_DIR}
            ''')
    }
}

but no success. Basically, I want to set the property Restrict where this project can run through Job DSL plugin

like image 592
Naveen Avatar asked Mar 09 '23 03:03

Naveen


1 Answers

The label method sets the Restrict where this project can run on job level:

job('example') {
    label('agentA agentB')
}

See the API viewer for details: https://jenkinsci.github.io/job-dsl-plugin/#path/job-label

like image 67
daspilker Avatar answered Mar 14 '23 19:03

daspilker