Summit
Summit

Reputation: 13

Jenkins DSL Script lightweight() checkout not working

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

Upvotes: 1

Views: 1603

Answers (3)

akostadinov
akostadinov

Reputation: 18654

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

pipelineJob(ITEM_PATH) {
    ...
    definition {
        ...
        cpsScm {
            ...
            lightweight(true)
        }
    }
}

Upvotes: 0

Summit
Summit

Reputation: 13

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)
    }
  }
}

Upvotes: 0

Mor Lajb
Mor Lajb

Reputation: 2636

try add the follow

pipelineJob('') {
  label('')
  definition {
    cpsScmFlowDefinition {
      scm {
        git {
          remote {
            url('')
            credentials('')
          }
          branch('')
          extensions {
            cleanBeforeCheckout()
            localBranch()
          }
        }
      }
      scriptPath('')
      configure {
         lightweight(true)
      }
    }
  }
}

Upvotes: 0

Related Questions