-
Type:
Bug
-
Status: Open (View Workflow)
-
Priority:
Major
-
Resolution: Unresolved
-
Component/s: bitbucket-plugin, mercurial-plugin
-
Labels:None
-
Environment:Jenkins 2.99
Pipeline: Multibranch 2.16
Bitbucket Plugin 1.1.8
Mercurial Plugin 2.2
-
Similar Issues:
In my multibranch job I see mercurial build data twice as discussed elsewhere. However this breaks the bitbucketPush() and pollSCM trigger, at least on my single instance, build on master setup. The below output from the bitbucket hook log shows the second checkout can't find any new changes and so does not trigger the build.
[EE594BC60F600AD3DD68DECB293CF28AC8C8D9FF-testrepo] $ hg pull pulling from https://bitbucket.org/aphtech/testrepo searching for changes adding changesets adding manifests adding file changes added 1 changesets with 1 changes to 1 files (run 'hg update' to get a working copy) Master cache lock released. [EE594BC60F600AD3DD68DECB293CF28AC8C8D9FF-testrepo] $ hg log --rev f9086558ba7491029c1dc288c81536bb666b1fd8 --template {node} [EE594BC60F600AD3DD68DECB293CF28AC8C8D9FF-testrepo] $ hg log --rev f9086558ba7491029c1dc288c81536bb666b1fd8 --template {rev} [EE594BC60F600AD3DD68DECB293CF28AC8C8D9FF-testrepo] $ hg id --branch --rev f9086558ba7491029c1dc288c81536bb666b1fd8 Acquired master cache lock. [EE594BC60F600AD3DD68DECB293CF28AC8C8D9FF-testrepo] $ hg pull pulling from https://bitbucket.org/aphtech/testrepo searching for changes no changes found Master cache lock released. [EE594BC60F600AD3DD68DECB293CF28AC8C8D9FF-testrepo] $ hg log --rev f9086558ba7491029c1dc288c81536bb666b1fd8 --template {node} [EE594BC60F600AD3DD68DECB293CF28AC8C8D9FF-testrepo] $ hg log --rev f9086558ba7491029c1dc288c81536bb666b1fd8 --template {rev} [EE594BC60F600AD3DD68DECB293CF28AC8C8D9FF-testrepo] $ hg id --branch --rev f9086558ba7491029c1dc288c81536bb666b1fd8 Done. Took 2.2 sec No changes
My base Jenkinsfile is pretty basic
pipeline { agent any triggers { bitbucketPush() } stages { stage("Build Data") { steps { sh 'echo yay' } } } }
I've tried with `checkout scm`, `skipDefaultCheckout()`, and inside a docker agent instead of master but cannot get rid of the second repo
Steps to reproduce
- Make a multibranch job from a mercurial repo on bitbucket
- Let it do the initial build, mercurial build data should be duplicated
- # Add bitbucket-hook/ url to bitbucket webhooks
- Try to trigger via push or pollSCM
This bug makes multibranch almost unusable
I decided to troubleshoot this more. I can't for the life of me get a multibranch pipeline to trigger. In the jenkins.log, it says:
INFO: Triggering BitBucket job default
I see in the Bitbucket Hook Log that it runs "/usr/bin/hg pull" and that the new changesets DO get pulled in, but for some reason it always says "No changes" and doesn't trigger the pipeline to run no matter what I do. So for whatever reason, multibranch pipelines with Bitbucket and Mercurial seem to be broken.
We don't use branches in these repos so I created a regular pipeline project (not sure why I didn't do this in the first place). I CAN get these to run on a push, but it creates duplicate changelog entries. In the Bitbucket Hook Log, I see a series of Mercurial commands run twice. The pipeline is called "test-staging" so I see "hg pull" etc. run for "test-staging@script" and then again for "test-staging". I assume the first one is to pull in the Jenkinsfile and the second is the default SCM checkout.
If I add this to the Jenkinsfile:
Then I see exactly one changelog entry per commit. Of course, the local repo is never updated, so I added a "Checkout" stage that runs "hg update" (because the changesets were already pulled down by the pipeline itself). This seems to work well for us.
Of course, this won't work on the initial pipeline setup because the repo has to be cloned first, but in that case all you need to do is leave out skipDefaultCheckout() on the first run then add it back in after that.