簡體   English   中英

Jenkins DSL 腳本輕量級()結帳不起作用

[英]Jenkins DSL Script lightweight() checkout not working

所以,這是我用來在 Jenkins 中創建作業的 pipelineJob() Jenkins DSL 腳本,但是當我在 cpsScmFlowDefinition 中使用輕量級 () 時,這個腳本不起作用並給我一個錯誤,我在下面粘貼了它。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM