We're using mercurial as our SCM exclusively, in combination with Jenkins, thanks to this plugin.
When Branch Indexing is being run (either triggered or manually), on a multibranch pipeline job, it normally iterates over all the fetched heads to find the Jenkinsfile for each. This is a feature that seems to be added in v 1.58 of the mercurial plugin. However, if one of the branches in the repository does not have a Jenkinsfile, the indexing is terminated with status failed.
[ED1EAACEE3A3A53C6B19AA947A23C57976B19FFE-SOMEJOB] $ /usr/bin/hg --config auth.jenkins.prefix=* --config ******** --config ******** --config "auth.jenkins.schemes=http https" locate -r b8b87f2c24b721d475750dfbba88c63bf2bda060 -I path:Jenkinsfile
ERROR: Failed to run /usr/bin/hg --config auth.jenkins.prefix=* --config auth.jenkins.username=CLEARTXTUSER --config auth.jenkins.password=CLEARTXTPASS --config "auth.jenkins.schemes=http https" locate -r b8b87f2c24b721d475750dfbba88c63bf2bda060 -I path:Jenkinsfile
ERROR: [Thu Feb 23 07:57:10 UTC 2017] Could not fetch branches from source 82b88e38-6997-4253-8e0d-7211e698983b
[Thu Feb 23 07:57:10 UTC 2017] Finished branch indexing. Indexing took 5.2 sec
This problem can be reproduced consistently using the mercurial plugin v1.58 or 1.59, by:
- Configure a multibranch pipeline job with Mercurial repository, with:
- One or more branches in repo
- At least one branch without Jenkinsfile
- Trigger the 'Scan Multibranch Pipeline' (either manually or on commit)
The interaction between Mercurial plugin and Branch API is fairly complex, but my estimation is that the below section of code is throwing an exit code of 1 when no Jenkinsfile is present. This subsequently causes the branch indexing to fail (with exception thrown).
From what I understand of it, the Branch API is designed to throw the exception and stop trying. This would mean that the Mercurial plugin can't pass exit code 1 when a Jenkinsfile is missing.
Note that both the methods committed over the last months, 'hg files' and 'hg locate' exit with code 1 if no pattern match is found.
Rollback to Mercurial plugin v1.57 resolved the issue and allows the branch indexing to complete. Of course it removes some of the new and desirable behavior introduced for properly tracking the pipeline enabled branches and marking closed branches.
|Status||Open [ 1 ]||In Progress [ 3 ]|
|Status||In Progress [ 3 ]||In Review [ 10005 ]|
|Assignee||Mathieu SEBIRE [ msebire ]|
|Assignee||Mathieu SEBIRE [ msebire ]||Jesse Glick [ jglick ]|
|Remote Link||This issue links to "PR 107 (Web Link)" [ 17463 ]|
|Resolution||Fixed [ 1 ]|
|Status||In Review [ 10005 ]||Resolved [ 5 ]|