This question is related to the Jenkins job auto trigger with multiple repositories.
Defined 3 repo's to checkout in Jenkinsfile.
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}
}
Configured Jenkins job using Github organization plugin.
In this case my Jenkinsfile is in abc repo and the Jenkins auto trigger is working fine for the abc repo. its not working for other repo's.
Is there anyway to define auto trigger for 2 or more repo's?
Is there any plugin which can auto trigger job for 2 or more repositories?
Do I need to define "checkout scm" different way in Jenkinsfile?
To create an Organization Folder in Jenkins, go to: New Item → GitHub Organization or New Item → Bitbucket Team and follow the configuration steps for each item, making sure to specify appropriate Scan Credentials and a specific owner for the GitHub Organization or Bitbucket Team name, respectively.
Yes, you can do that with the Pipeline script from SCM
option in a pipeline job by specifying multiple repositories (click on Add Repository
button), assuming you can watch the same branch for your 3 repositories, which seems to be your case.
With this configuration (and of course the Poll SCM
option activated), a build will be triggered every time a change is made to one of your three repositories.
A few more hints about this solution:
Jenkinsfile
in each repository
SCM polls
the result will be unpredictable (either one of the two projects you just committed in could finally get built) so you should not depend on which project gets built.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'
}()
common-pipeline.groovy
script:{ ->
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...
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With