使用DSL在Jenkins pipelinejob中配置块?

使用DSL在Jenkins pipelinejob中配置块?,jenkins,jenkins-pipeline,jenkins-job-dsl,Jenkins,Jenkins Pipeline,Jenkins Job Dsl,尝试使用jobs DSL编写DSL Jenkins管道作业,但不确定我是否遇到了一些管道作业限制,或者遗漏了一些更基本的内容 1-使用配置块在“其他行为”下配置“轮询忽略某些路径中的提交”似乎没有按照管道作业中的预期工作;我已经测试过,这个配置块在一个自由式作业dsl中按预期工作。已搜索但找不到任何相关内容-是否有人可以确认以下管道作业中是否支持/不支持以下内容 pipelineJob("ProjA/pipeline") { logRotator

尝试使用jobs DSL编写DSL Jenkins管道作业,但不确定我是否遇到了一些管道作业限制,或者遗漏了一些更基本的内容

1-使用配置块在“其他行为”下配置“轮询忽略某些路径中的提交”似乎没有按照管道作业中的预期工作;我已经测试过,这个配置块在一个自由式作业dsl中按预期工作。已搜索但找不到任何相关内容-是否有人可以确认以下管道作业中是否支持/不支持以下内容

    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')
                }
              }
           }
        }
     }
管道作业(“项目/管道”) { 对数旋转器 { 第10天 numToKeep 30 } 定义 { CPSSM { 供应链管理 { 吉特('git@github.com:sample org/pipeline.git',“*/developer') } 配置{gitScm->
gitScm/“扩展”FYI用于正常管道

使用引用以下内容的凭据进行Git签出:


我从来没有在寻找民意测验,看它对正常管道是否有效

使用引用以下内容的凭据进行Git签出:


而且我从来没有考虑过poll是否有效

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

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

但是这是为了在Jenkins文件中使用,而不是为了。这不一定是错误的。只是可以澄清的是,这不能仅仅插入作者发布的剪贴。不,Job DSL,一个单独的插件(参见)谢谢@xxxvodnikxxx-但正如StephenKing提到的,正在寻找一个等同于PipelineJob的jobs dsl,但这是在Jenkins文件中使用的,而不是。这不一定是错的。只是需要澄清的是,这不能仅仅插入作者发布的剪贴。不,Job dsl,一个单独的插件(请参阅)谢谢@xxxvodnikxxx-但是正如StephenKing提到的,正在寻找一个与pipelinejob中使用的工作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')
    }
  }
}