![](/img/trans.png)
[英]How to trigger a Jenkins multibranch pipeline when code change is pushed to GitHub
[英]Jenkins DSL multibranch pipeline github push trigger
我正在使用 jenkins dsl 插件 multibranchpipeline 作業( https://jenkinsci.github.io/job-dsl-plugin/#path/multibranchPipelineJob )來創建多分支管道。 我創建了 jenkinsfile 來處理每個分支的構建作業。 我無法弄清楚如何通過管道作為代碼啟用 github 推送觸發器。 我能找到的所有示例都使用了 jenkins web UI 或 pollscm 選項。 有人可以幫助了解如何通過代碼啟用此功能。
項目托管在 github。在 jenkins dsl multibranchpipeline 中,我首先使用的是 git branchsource。 然后推送事件不會觸發構建。 在我開始使用 github branchsource 之后,推送事件會自動生成構建。
IE。
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')
}
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.