Jenkins Mercurial plugin does not detect changes

微笑、不失礼 提交于 2019-12-13 02:58:25

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!