jenkins 如何为 pipelineJob 启用轻量级结帐?

jenkins how to enable checkout lightweight for pipelineJob?

这是我的作业 DSL,它创建了从 scm 本身获取脚本的管道作业。

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

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

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

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

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

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

我尝试将 Configure Block 用于 lightweight() 但它 对我有用。

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

根据 this 维基,这必须是这样的

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