使用 DSL 在 Jenkins pipelinejob 中配置块?
Configure block in Jenkins pipelinejob using DSL?
尝试使用 jobs-dsl 编写 DSL Jenkins 管道作业,但不确定我是否遇到了一些管道作业限制或遗漏了一些更基本的东西。
1 - 使用配置块在 "Additional Behaviours" 下配置 "Polling ignores commits in certain paths" 在管道作业中似乎没有按预期工作;我已经测试过,这个配置块在自由式作业 dsl 中按预期工作。搜索但找不到任何相关内容 - 有人可以确认以下是否 supported/not 在以下管道作业中受支持吗?
pipelineJob("ProjA/pipeline")
{
logRotator
{
daysToKeep 10
numToKeep 30
}
definition
{
cpsScm
{
scm
{
git('git@github.com:sample-org/pipeline.git', '*/develop')
}
configure { gitScm ->
gitScm / 'extensions' << 'hudson.plugins.git.extensions.impl.PathRestriction' {
excludedRegions('sample/dirs')
}
}
}
}
}
2 - 我们如何将凭据传递到管道下 scm 块下的 git?适用于自由式工作,但无法在这里工作
提前致谢。
正常管道仅供参考
Git 使用引用 git plugin step 的凭据结帐:
stage('checkout') {
git credentialsId: '<credentialsID from credentials plugin>',
url: 'git@repository.foo/repoName.git',
branch: 'master'
}
注册。 scm plugin step
stage('checkout') {
checkout scm: [$class: 'GitSCM',
userRemoteConfigs: [[url: 'https://repository.foo/git/fooRepoName.git' ,
credentialsId: 'credentialsIDToUseFromCredentialsPlugin']],
branches: [[name:'refs/tags/TAGNAME']]],
poll:false
}
stage('checkout') {
checkout scm: [$class: 'GitSCM',
userRemoteConfigs: [[url: 'https://repository.foo/git/fooRepoName.git' ,
credentialsId: 'credentialsIDToUseFromCredentialsPlugin']],
branches: [[name:'BRANCHNAME']]],
poll:false
}
而且我从来没有在寻找投票是否有效
内置DSL仅支持基本选项。但是 Dynamic DSL 几乎支持任何选项。
pipelineJob('example') {
definition {
cpsScmFlowDefinition {
scm {
gitSCM {
userRemoteConfigs {
userRemoteConfig {
url('git@github.com:sample-org/pipeline.git')
name('master')
refspec(null)
credentialsId('example')
}
}
branches {
branchSpec {
name('*/develop')
}
}
extensions {
pathRestriction {
includedRegions(null)
excludedRegions('sample/dirs')
}
}
doGenerateSubmoduleConfigurations(false)
browser {}
gitTool(null)
}
}
scriptPath('Jenkinsfile')
}
}
}
尝试使用 jobs-dsl 编写 DSL Jenkins 管道作业,但不确定我是否遇到了一些管道作业限制或遗漏了一些更基本的东西。
1 - 使用配置块在 "Additional Behaviours" 下配置 "Polling ignores commits in certain paths" 在管道作业中似乎没有按预期工作;我已经测试过,这个配置块在自由式作业 dsl 中按预期工作。搜索但找不到任何相关内容 - 有人可以确认以下是否 supported/not 在以下管道作业中受支持吗?
pipelineJob("ProjA/pipeline")
{
logRotator
{
daysToKeep 10
numToKeep 30
}
definition
{
cpsScm
{
scm
{
git('git@github.com:sample-org/pipeline.git', '*/develop')
}
configure { gitScm ->
gitScm / 'extensions' << 'hudson.plugins.git.extensions.impl.PathRestriction' {
excludedRegions('sample/dirs')
}
}
}
}
}
2 - 我们如何将凭据传递到管道下 scm 块下的 git?适用于自由式工作,但无法在这里工作
提前致谢。
正常管道仅供参考
Git 使用引用 git plugin step 的凭据结帐:
stage('checkout') {
git credentialsId: '<credentialsID from credentials plugin>',
url: 'git@repository.foo/repoName.git',
branch: 'master'
}
注册。 scm plugin step
stage('checkout') {
checkout scm: [$class: 'GitSCM',
userRemoteConfigs: [[url: 'https://repository.foo/git/fooRepoName.git' ,
credentialsId: 'credentialsIDToUseFromCredentialsPlugin']],
branches: [[name:'refs/tags/TAGNAME']]],
poll:false
}
stage('checkout') {
checkout scm: [$class: 'GitSCM',
userRemoteConfigs: [[url: 'https://repository.foo/git/fooRepoName.git' ,
credentialsId: 'credentialsIDToUseFromCredentialsPlugin']],
branches: [[name:'BRANCHNAME']]],
poll:false
}
而且我从来没有在寻找投票是否有效
内置DSL仅支持基本选项。但是 Dynamic DSL 几乎支持任何选项。
pipelineJob('example') {
definition {
cpsScmFlowDefinition {
scm {
gitSCM {
userRemoteConfigs {
userRemoteConfig {
url('git@github.com:sample-org/pipeline.git')
name('master')
refspec(null)
credentialsId('example')
}
}
branches {
branchSpec {
name('*/develop')
}
}
extensions {
pathRestriction {
includedRegions(null)
excludedRegions('sample/dirs')
}
}
doGenerateSubmoduleConfigurations(false)
browser {}
gitTool(null)
}
}
scriptPath('Jenkinsfile')
}
}
}