本文介绍了Jenkins JobDSL multibranchPipelineJob更改脚本路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在jobDSL中创建一个multibranchPipelineJob,但是Jenkinsfile位于默认位置的替代位置.我已经浏览了文档 https://jenkinsci.github.io/job- dsl-plugin/#path/multibranchPipelineJob 我看不到这样做的方法.在手动创建的multibranchPipelineJob的config.xml中,该脚本路径位于该部分中,但是我找不到设置该设置的DSL方法.

I am trying to create a multibranchPipelineJob in jobDSL, however the Jenkinsfile is at an alternative location to the default.I have looked through the docs https://jenkinsci.github.io/job-dsl-plugin/#path/multibranchPipelineJoband I cannot see a way to do this.Looking at the config.xml for a manually created multibranchPipelineJob the scriptPath is in the section, but I cannot find a DSL method to set this.

有人可以提供有关此操作的任何帮助吗?干杯

Can anyone offer any help on how to do this?Cheers

推荐答案

Job DSL现在提供了一种执行此操作的方法:

Job DSL now exposes a way to do this:

multibranchPipelineJob('my-build') {
    factory {
        workflowBranchProjectFactory {
            scriptPath('path-to-Jenkinsfile')
        }
    }
}

确认可以使用Job DSL 1.69,并且根据发行说明自1.67开始可用.

Confirmed working with Job DSL 1.69, and is available since 1.67 according to the release notes.

使用Job DSL 1.77进行了再次测试,它仍然可以正常工作.如果要查看此语法的文档,则必须在以下路径下查看安装了Multibranch Pipeline插件的Jenkins安装:

Tested again with Job DSL 1.77 and it's still working as expected. If you want to see the documentation for this syntax you'll have to look at a Jenkins installation that has the Multibranch Pipeline plugin installed, at this path:

https://your-jenkins-url/plugin/job-dsl/api-viewer/index.html#path/multibranchPipelineJob-factory-workflowBranchProjectFactory-scriptPath

https://your-jenkins-url/plugin/job-dsl/api-viewer/index.html#path/multibranchPipelineJob-factory-workflowBranchProjectFactory-scriptPath

这篇关于Jenkins JobDSL multibranchPipelineJob更改脚本路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 02:28