Nit*_*tin 14 jenkins github-organizations jenkins-pipeline jenkinsfile
此问题与具有多个存储库的Jenkins作业自动触发器有关.
在Jenkinsfile中定义了3个repo来结账.
node('slave'){
git clone github.com/owner/abc.git -b ${env.BRANCH_NAME}
git clone github.com/owner/def.git -b ${env.BRANCH_NAME}
git clone github.com/owner/ghi.git -b ${env.BRANCH_NAME}
}
Run Code Online (Sandbox Code Playgroud)
使用Github组织插件配置Jenkins作业.
在这种情况下,我的Jenkinsfile在abc repo中,并且Jenkins自动触发器对于abc repo工作正常.它不适合其他回购.
反正有没有为2个或更多回购定义自动触发?
是否有任何插件可以自动触发2个或更多存储库的作业?
我需要在Jenkinsfile中以不同的方式定义"checkout scm"吗?
是的,您可以Pipeline script from SCM通过指定多个存储库(单击Add Repository按钮)来管理作业中的选项,假设您可以为3个存储库查看相同的分支,这似乎就是您的情况.
使用此配置(当然还有Poll SCM激活的选项),每次对三个存储库之一进行更改时,都会触发构建.
关于此解决方案的一些提示:
JenkinsfileSCM polls,结果将是不可预测的(您刚刚提交的两个项目中的任何一个最终都可以构建),因此您不应该依赖于构建哪个项目.node {
// --- Load the generic pipeline ---
checkout scm: [$class: 'GitSCM', branches: [[name: '*/master']], extensions: [], submoduleCfg: [], userRemoteConfigs: [[url: 'http://github/owner/pipeline-repo.git']]]
load 'common-pipeline.groovy'
}()
Run Code Online (Sandbox Code Playgroud)
common-pipeline.groovy 脚本:{ ->
node() {
git clone github.com/owner/abc.git
git clone github.com/owner/def.git
git clone github.com/owner/ghi.git
// Whatever you do with your 3 repos...
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9875 次 |
| 最近记录: |