【问题标题】:jenkins how to enable checkout lightweight for pipelineJob?jenkins 如何为 pipelineJob 启用结帐轻量级?
【发布时间】:2017-09-28 14:39:37
【问题描述】:

这是我的工作 DSL,它创建了从 scm 本身获取脚本的 pipelinejob。

pipelineJob ("${jobName}_deploy") {
  description("built by seed")

definition {
     cpsScm {
        scm {
            git {
                remote {
                    url('gitUrl')
                    credentials('user_creds')
                }
              branch('master')
            }
        }
        scriptPath "scripts/pipeline/jenkinsfile_deploy"
    }
 }
 }

我需要自动检查轻量级结帐。

任何帮助将不胜感激。我有很多工作,我需要打开每一个工作并单击那个很痛苦的复选框。

【问题讨论】:

    标签: jenkins jenkins-pipeline jenkins-job-dsl


    【解决方案1】:

    您可以使用Configure Block 添加内置 DSL 中缺少的任何选项:

    pipelineJob('example') {
      definition {
        cpsScm {
          // ...
        } 
      }
      configure {
         it / definition / lightweight(true)
      }
    }
    

    【讨论】:

    • @daspiker 非常感谢。这很强大。我喜欢 JOB DSL。
    【解决方案2】:

    我尝试将 Configure Block 用于轻量级(),但它不对我有用。

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

    【讨论】:

      【解决方案3】:

      根据this wiki,必须是这样的

      pipelineJob('job-name') {
      
        description('''
      Job description
      ''')
      
        definition {
          cpsScm {
            lightweight(true)
            scm {
              git {
                remote {
                  url('git@github.com:arulrajnet/attila.git')
                  credentials('CREDENTIAL_ID')
                }
                branches('*/master')
              }
            }
            scriptPath('build.groovy')
          }
        }
      }
      

      【讨论】:

        猜你喜欢
        • 2022-07-19
        • 1970-01-01
        • 1970-01-01
        • 2021-12-13
        • 2022-08-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多