Jenkins JobDSL multibranchPipelineJob 更改脚本路径 [英] Jenkins JobDSL multibranchPipelineJob change script path

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

问题描述

我正在尝试在 jobDSL 中创建一个 multibranchPipelineJob,但是 Jenkinsfile 位于默认位置的替代位置.我浏览了文档 https://jenkinsci.github.io/job-dsl-plugin/#path/multibranchPipelineJob而且我看不到这样做的方法.查看手动创建的 multibranchPipelineJob 的 config.xml,scriptPath 位于该部分中,但我找不到 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/multibranchPipelineJob and 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 更改脚本路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆