So, here is my pipelineJob() Jenkins DSL Script that I am using to create Jobs in Jenkins, but when I use lightweight() in cpsScmFlowDefinition, this script doesn't work and gives me an error which I have pasted below.
Jenkins version 2.73.2 and DSL plugin version 1.66. Please help me to fix this issue. Thanks.
pipelineJob('') {
label('')
definition {
cpsScmFlowDefinition {
scm {
git {
remote {
url('')
credentials('')
}
branch('')
extensions {
cleanBeforeCheckout()
localBranch()
}
}
}
scriptPath('')
lightweight(true) // error while using this
}
}
}
ERROR:
Processing provided DSL script
ERROR: (script, line 14) No signature of method: javaposse.jobdsl.plugin.structs.DescribableListContext.git() is applicable for argument types: (script$_run_closure1$_closure4$_closure7$_closure8$_closure9) values: [script$_run_closure1$_closure4$_closure7$_closure8$_closure9@516b358d]
Possible solutions: wait(), wait(long), with(groovy.lang.Closure), is(java.lang.Object), grep(), find()
[BFA] Scanning build for known causes...
[BFA] No failure causes found
[BFA] Done. 0s
Collecting metadata...
Metadata collection done.
Started calculate disk usage of build
Finished Calculation of disk usage of build in 0 seconds
Started calculate disk usage of workspace
Finished Calculation of disk usage of workspace in 0 seconds
Finished: FAILURE
The thing I did to solve this issue is to use cpsScmFlowDefinition() like this:
pipelineJob('example') {
definition {
cpsScmFlowDefinition {
scm {
gitSCM {
userRemoteConfigs {
userRemoteConfig {
credentialsId('')
name('')
refspec('')
url('')
}
}
branches {
branchSpec {
name('')
}
}
extensions {
cleanBeforeCheckout()
localBranch {
localBranch('')
}
}
doGenerateSubmoduleConfigurations(false)
browser {
gitWeb {
repoUrl('')
}
}
gitTool('')
}
}
scriptPath('')
lightweight(true)
}
}
}