简体   繁体   中英

Jenkins DSL job configuring slave

I have a DSL plugin file which creates couple of jobs like pipeline, freshly jobs. I wanted to know what would be syntax (for dsl file only not jenkinsfile) that i can run these jobs on specific agent or slave. Code sample given below. I tried to use label('JenkinsEC2Slave'),But it is actually running my DSL job on slave, not the one which are created by DSL. Labels are from ec2 plugin and they should be launched on demand.

pipelineJob('Build_Docker_Images') {
 label('JenkinsEC2Slave')   
configure {
     it / definition / lightweight(true)
}
triggers {
    scm('@midnight')
}
concurrentBuild(false)
parameters {
    stringParam('ECR_REPO', 'xxxxxxxxxxx.dkr.ecr.eu-west-2.amazonaws.com')

}
definition {
     cpsScm {
        scm {
            scriptPath ('ci-cd/pipelines/base_docker_images/Jenkinsfile')
            git {
                branches('*/master')
                remote {
                    url ('git@github.com:xxxxxxxxxx.git')
                    credentials ('jenkins-key')
                }
            }
        }
    }
}

You can use labels to select build agents in Jenkins. label is also the property of JobDSL, which allows you to specify labels for a job. Quoting the DSL viewer :

job('example') {
  label('x86 && ubuntu')
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM