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

问题描述 投票:0回答:4

这是我的工作 DSL,它创建 pipelinejob,其中脚本取自 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"
    }
 }
 }

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

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

jenkins jenkins-pipeline jenkins-job-dsl
4个回答
5
投票

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

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

0
投票

我尝试使用 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)
    }
  }
}

0
投票

根据 this wiki,这必须是这样的

pipelineJob('job-name') {

  description('''
Job description
''')

  definition {
    cpsScm {
      lightweight(true)
      scm {
        git {
          remote {
            url('[email protected]:arulrajnet/attila.git')
            credentials('CREDENTIAL_ID')
          }
          branches('*/master')
        }
      }
      scriptPath('build.groovy')
    }
  }
}

0
投票

如果您使用普通的 git 插件,请使用

changelog
设置:

            steps {
                git branch: 'main',
                    credentialsId: 'key_git_id',
                    changelog: false,
                    url: '[email protected]:mysuperteam/mybestproject.git'

            }

Jenkins Git 插件文档说:

changelog :布尔值(可选)计算此作业的变更日志。默认值为“true”。

如果变更日志为 false,则不会为此作业计算变更日志。如果变更日志为 true 或未设置,则将计算变更日志。

© www.soinside.com 2019 - 2024. All rights reserved.