1

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
Zoe
  • 27,060
  • 21
  • 118
  • 148
Summit
  • 13
  • 1
  • 7

3 Answers3

0

try add the follow

pipelineJob('') {
  label('')
  definition {
    cpsScmFlowDefinition {
      scm {
        git {
          remote {
            url('')
            credentials('')
          }
          branch('')
          extensions {
            cleanBeforeCheckout()
            localBranch()
          }
        }
      }
      scriptPath('')
      configure {
         lightweight(true)
      }
    }
  }
}
Mor Lajb
  • 2,546
  • 1
  • 15
  • 28
0

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)
    }
  }
}
Summit
  • 13
  • 1
  • 7
0

For anybody that looks for this, this is how it works in recent jenkins (2.190):

pipelineJob(ITEM_PATH) {
    ...
    definition {
        ...
        cpsScm {
            ...
            lightweight(true)
        }
    }
}
akostadinov
  • 17,364
  • 6
  • 77
  • 85