这是我的工作 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"
}
}
}
任何帮助将不胜感激。我有很多工作,我需要打开每一个工作并单击该复选框,这很痛苦。
您可以使用配置块添加内置 DSL 中缺少的任何选项:
pipelineJob('example') {
definition {
cpsScm {
// ...
}
}
configure {
it / definition / lightweight(true)
}
}
我尝试使用 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)
}
}
}
根据 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')
}
}
}
如果您使用普通的 git 插件,请使用
changelog
设置:
steps {
git branch: 'main',
credentialsId: 'key_git_id',
changelog: false,
url: '[email protected]:mysuperteam/mybestproject.git'
}
Jenkins Git 插件文档说:
changelog :布尔值(可选)计算此作业的变更日志。默认值为“true”。
如果变更日志为 false,则不会为此作业计算变更日志。如果变更日志为 true 或未设置,则将计算变更日志。