Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-42278

Branch indexing failing on MultiBranch Pipeline when at least one branch has no Jenkinsfile

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Blocker
    • Resolution: Fixed
    • Component/s: mercurial-plugin
    • Labels:
    • Environment:
      Jenkins 2.32.2, Branch API plugin 2.0.7, Mercurial plugin 1.58 and 1.59
    • Similar Issues:

      Description

      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.

      Exception

      [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
      hudson.AbortException
      at hudson.plugins.mercurial.HgExe.popen(HgExe.java:425)
      at hudson.plugins.mercurial.MercurialSCMSource$1.stat(MercurialSCMSource.java:150)
      at org.jenkinsci.plugins.workflow.multibranch.WorkflowBranchProjectFactory$1.isHead(WorkflowBranchProjectFactory.java:52)
      at hudson.plugins.mercurial.MercurialSCMSource.retrieve(MercurialSCMSource.java:176)
      at jenkins.scm.api.SCMSource._retrieve(SCMSource.java:300)
      at jenkins.scm.api.SCMSource.fetch(SCMSource.java:210)
      at jenkins.branch.MultiBranchProject.computeChildren(MultiBranchProject.java:628)
      at com.cloudbees.hudson.plugins.folder.computed.ComputedFolder.updateChildren(ComputedFolder.java:219)
      at com.cloudbees.hudson.plugins.folder.computed.FolderComputation.run(FolderComputation.java:154)
      at jenkins.branch.MultiBranchProject$BranchIndexing.run(MultiBranchProject.java:967)
      at hudson.model.ResourceController.execute(ResourceController.java:98)
      at hudson.model.Executor.run(Executor.java:404)
      [Thu Feb 23 07:57:10 UTC 2017] Finished branch indexing. Indexing took 5.2 sec
      FATAL: null
      Finished: FAILURE

      How to reproduce

      This problem can be reproduced consistently using the mercurial plugin v1.58 or 1.59, by:

      1. Configure a multibranch pipeline job with Mercurial repository, with:
        1. One or more branches in repo
        2. At least one branch without Jenkinsfile
      2. Trigger the 'Scan Multibranch Pipeline' (either manually or on commit)

      Likely cause

      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).

      https://github.com/jenkinsci/mercurial-plugin/blob/master/src/main/java/hudson/plugins/mercurial/MercurialSCMSource.java#L151

      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.

      Workaround

      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.

        Attachments

          Issue Links

            Activity

            wynx WynX Alucard created issue -
            markl_lagendijk Mark Lagendijk made changes -
            Field Original Value New Value
            Link This issue is duplicated by JENKINS-43406 [ JENKINS-43406 ]
            jglick Jesse Glick made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            jglick Jesse Glick made changes -
            Status In Progress [ 3 ] In Review [ 10005 ]
            jglick Jesse Glick made changes -
            Assignee Mathieu SEBIRE [ msebire ]
            jglick Jesse Glick made changes -
            Assignee Mathieu SEBIRE [ msebire ] Jesse Glick [ jglick ]
            jglick Jesse Glick made changes -
            Remote Link This issue links to "PR 107 (Web Link)" [ 17463 ]
            jglick Jesse Glick made changes -
            Status In Review [ 10005 ] Resolved [ 5 ]
            Resolution Fixed [ 1 ]
            jglick Jesse Glick made changes -
            Labels regression

              People

              • Assignee:
                jglick Jesse Glick
                Reporter:
                wynx WynX Alucard
              • Votes:
                8 Vote for this issue
                Watchers:
                12 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: