At the Jenkinsfile with two git repositories these is an example of using multiple GIT repositories in a single Jenkins job:
node {
dir('RepoOne') {
git url: 'https://github.com/somewhere/RepoOne.git'
}
dir('RepoTwo') {
git url: 'https://github.com/somewhere/RepoTwo.git'
}
sh('. RepoOne/build.sh')
sh('. RepoTwo/build.sh')
}
How can I configure this job to track SCM changes of these 2 repositories so that the job triggers each time when at least one of repositories has updates?
The problem is that the job is polling not the repositories mentioned inside Jenkinsfile, but the repository of the Jenkinsfile itself (it is stored in a special repository, not with the source code together) which is mentioned in the GUI configuration of the job.
With the old Jenkins (without coded pipeline) and SVN plugin it was very easy, because all N repositories could be mentioned in the GUI configuration, checked out to a separate sub-directories of the single workspace and simultaneously polled.
How can I reach the same result with GIT + Jenkins Pipeline-As-Code? I tried to use also "poll: true" option in the Jenkinsfile, but it did not help. What does then this option do?
UPDATE 1: Here is the pipeline script which I really use and which does not work:
properties([
pipelineTriggers([
scm('H/5 * * * *')
])
])
node {
stage ('Checkout') {
dir('cplib') {
git(
poll: true,
url: 'ssh://git@<server>:<port>/base/cplib.git',
credentialsId: 'BlueOceanMsl',
branch: 'master'
)
}
dir('cpmffmeta') {
git(
poll: true,
url: 'ssh://git@<server>:<port>/base/cpmffmeta.git',
credentialsId: 'BlueOceanMsl',
branch: 'master'
)
}
}
stage ('Build') {
...
}
I found the cause of the problem. It was a fault described by https://issues.jenkins-ci.org/browse/JENKINS-37731. I used a wrong syntax. The correct one looks so:
properties([
pipelineTriggers([
[$class: "SCMTrigger", scmpoll_spec: "H/5 * * * *"],
])
])
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