问题
When my pipeline polls the Mercurial repo for changes it does not detect any change, and new builds are not triggered.
Following the plugin docs, I set up a push hook to trigger the polling, which works fine, but is not able to detect changes. All I get is
Mercurial Polling Log
Started on May 19, 2018 11:58:10 PM
no polling baseline in /var/lib/jenkins/workspace/test-repo on
Done. Took 0 ms
No changes
I am working with: - Jenkins v2.107.3 - Mercurial plugin v2.3
I just created a test mercurial repo with some files with random content to test the setup, and a jenkins pipeline 'polling-test' which checks out the repo and echoes "hello world".
pipeline {
agent any
stages {
stage('Checkout') {
steps {
checkout changelog: true,
poll: true,
scm: [
$class: 'MercurialSCM',
credentialsId: 'jenkins',
revision: 'default',
revisionType: 'BRANCH',
source: 'ssh://hg-user@hg-server/test-repo'
]
}
}
stage('Tests') {
steps {
echo "Hello World"
}
}
}
}
Also the Poll SCM option is checked out, and without any schedule.
I modify the repo doing something like:
$ echo "foo" > bar
$ hg add bar
$ hg commit -m "change"
$ hg push
And then the polling is triggered with
$ curl "https://jenkins-server/mercurial/notifyCommit?url=ssh://hg-user@hg-server/test-repo"
Scheduled polling of polling-test
The polling log shows it has triggered, but found no changes.
What am I doing wrong? How can changes be detected?
回答1:
I was able to make the polling work properly by adding a Mercurial installation in the "global tools", changing the pipeline script to
pipeline {
agent any
stages {
stage('Checkout') {
steps {
checkout([$class: 'MercurialSCM', credentialsId: 'jenkins', installation: 'Mercurial', source: 'ssh://hg-user@hg-server/test-repo'])
}
}
stage('Tests') {
steps {
echo "Hello World"
}
}
}
}
while keeping the Polling option checked, and of course running the pipeline a first time manually to get a reference changeset.
来源:https://stackoverflow.com/questions/50430020/jenkins-mercurial-plugin-does-not-detect-changes