Jenkins DSL脚本轻量级()结账无效

时间:2017-10-26 20:59:54

标签: jenkins plugins dsl vcs-checkout

所以,这是我用来在Jenkins中创建Jobs的我的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
    }
  }
}

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

3 个答案:

答案 0 :(得分:0)

尝试添加以下

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

答案 1 :(得分:0)

我为解决这个问题所做的就是像这样使用 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)
    }
  }
}

答案 2 :(得分:0)

对于任何想要这个的人来说,这就是最近的詹金斯(2.190)中的工作方式:

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