-
Bug
-
Resolution: Not A Defect
-
Minor
-
None
-
Job-dsl-plugin: 1.74
Jenkins: 2.176.1
Job error:
No signature of method: javaposse.jobdsl.dsl.jobs.WorkflowJob.label() is applicable for argument types
I have defined a job pipeline DSL from SCM according to documentation:
node('master') { withEnv([ 'JENKINS_CREDENTIAL_ID_GITHUB=', 'GIT_BRANCH=development', 'GIT_REPO=git@github.com:x/x.git', 'GROOVY_SCRIPT_DIR=jenkinsfiles', 'GROOVY_SCRIPT_FILENAME=dslCreatePipeline.groovy' ]){ stage('Clean Workspace') { cleanWs() } stage('Clone sources') { git branch: "${env.GIT_BRANCH}", credentialsId: "${env.JENKINS_CREDENTIAL_ID_GITHUB}", url: "${env.GIT_REPO}" } stage("ExecuteDslScripts: ${GROOVY_SCRIPT_FILENAME}") { def repos = "a,b,c,d" dir("${env.GROOVY_SCRIPT_DIR}") { sh "echo CWD is `pwd`" // https://github.com/jenkinsci/job-dsl-plugin/wiki/User-Power-Moves#use-job-dsl-in-pipeline-scripts step([ $class: 'ExecuteDslScripts', targets: "${env.GROOVY_SCRIPT_FILENAME}", removedJobAction: 'IGNORE', removedViewAction: 'IGNORE', removedViewAction: 'IGNORE', lookupStrategy: 'SEED_JOB', additionalParameters: [REPO_LIST: "${repos}"] // repos PARAM was created manually ]) } } } }
This executes my groovy script, which fails when building with the error:
ERROR: (dslCreatePushPipeline.groovy, line 9) No signature of method: javaposse.jobdsl.dsl.jobs.WorkflowJob.label() is applicable for argument types: (java.lang.String) values: [swarm]
Here is "dslCreatePipeline.groovy" for reference. If there is proper way to set worker labels, let me know. This works fine when pasting the script into ""Process job DSL"" box inline so I am assuming there's a bug here.
def repoList = "${REPO_LIST}".trim().replaceAll('"', '').split(",") println "Generating PR push jobs for the following repos:: $repoList"repoList.each { def cookbook = it pipelineJob("${cookbook}-PR-push") { label('swarm') // this is throwing an error // why does this work without SCM? description("Chef push pipeline job") properties { githubProjectUrl("https://github.com/git_org/${cookbook}/") } scm { git { remote { github("git_org/${cookbook}", 'ssh') refspec('+refs/pull/*:refs/remotes/origin/pr/*') credentials('d6f6e9f1-43cb-4ea1-83da-e5581d3f9472') } branch('${ghprbActualCommit}') extensions { relativeTargetDirectory("${cookbook}") } configure { gitScm -> gitScm / 'extensions' << 'hudson.plugins.git.extensions.impl.UserExclusion' { excludedUsers('doxbot') } } } } triggers { githubPullRequest { admin('') orgWhitelist(['git_org']) triggerPhrase('jenkins push to \\S* \\S*') useGitHubHooks() onlyTriggerPhrase() extensions { commitStatus { context('Push cookbook pipeline') startedStatus() statusUrl() } } } } definition { cpsScm { lightweight(true) scriptPath('workflowPipeline.groovy') scm { git { branch('master') remote { github("git_org/jenkins-scripts", 'ssh') credentials('d6f6e9f1-43cb-4ea1-83da-e5581d3f9472') } } } } } } }