Jenkins DSL 脚本轻量级()结帐不起作用

Jenkins DSL Script lightweight() checkout not working

所以,这是我用来在 Jenkins 中创建作业的 pipelineJob() Jenkins DSL 脚本,但是当我在 cpsScmFlowDefinition 中使用 lightweight() 时,该脚本不起作用并给我一个错误粘贴在下面。

Jenkins 版本 2.73.2 和 DSL 插件版本 1.66。请帮我解决这个问题。谢谢

pipelineJob('') {
  label('')
  definition {
    cpsScmFlowDefinition {
      scm {
        git {
          remote {
            url('')
            credentials('')
          }
          branch('')
          extensions {
            cleanBeforeCheckout()
            localBranch()
          }
        }
      }
      scriptPath('')
      lightweight(true) // error while using this
    }
  }
}

错误:

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

尝试添加以下内容

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

我为解决这个问题所做的事情是像这样使用 cpsScmFlowDefinition()

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

对于寻找这个的任何人,这就是它在最近的 jenkins (2.190) 中的工作方式:

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