【问题标题】:Jenkins DSL multibranch pipeline github push triggerJenkins DSL 多分支管道 github 推送触发器
【发布时间】:2019-09-14 20:03:16
【问题描述】:

我正在使用 jenkins dsl 插件多分支管道作业(https://jenkinsci.github.io/job-dsl-plugin/#path/multibranchPipelineJob)来创建多分支管道。我创建了 jenkinsfile 来处理每个分支的构建作业。我无法弄清楚如何通过管道即代码启用 github 推送触发器。我能找到的所有示例都是使用 jenkins Web UI 或 pollscm 选项。有人可以帮助如何通过代码启用它。

【问题讨论】:

    标签: jenkins jenkins-pipeline jenkins-job-dsl multibranch-pipeline


    【解决方案1】:

    项目托管在 github。在 jenkins dsl multibranchpipeline 中,我最初使用的是 git 分支源。然后推送事件没有触发构建。在我开始使用 github 分支源之后,推送事件会自动生成构建。

    即。

    multibranchPipelineJob('example') {
    branchSources {
        git {
            id('12121212') // IMPORTANT: use a constant and unique identifier
            remote('https://github.com/jenkinsci/job-dsl-plugin.git')
            credentialsId('github-ci')
            includes('JENKINS-*')
        }
    }
    }
    

    改为

    multibranchPipelineJob('example') {
    branchSources {
        github {
            id('23232323') // IMPORTANT: use a constant and unique identifier
            scanCredentialsId('github-ci')
            repoOwner('OwnerName')
            repository('job-dsl-plugin')
        }
    }
    }
    

    【讨论】:

    • @JoSSI 感谢您指出,我只是接受它作为答案:)
    • 能否请您使用实际的作业-dsl 更新此答案,根据需要进行审查,显示正确的配置是什么样的以及它的去向?
    猜你喜欢
    • 2017-06-23
    • 1970-01-01
    • 2020-08-24
    • 1970-01-01
    • 2019-08-02
    • 1970-01-01
    • 2020-06-12
    • 2017-03-30
    • 1970-01-01
    相关资源
    最近更新 更多