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

Mercurial plugin cannot find installation in multibranch pipeline environment

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved (View Workflow)
    • Major
    • Resolution: Not A Defect
    • mercurial-plugin
    • None
    • Jenkins 2.73.1
      Mercurial 2.1
      Pipeline 2.5

    Description

      The mercurial plugin cannot find mercurial installation when multibranch pipeline configuration. 

      In the logs it says: 

       
      {{[Thu Sep 21 20:56:18 UTC 2017] Starting branch indexing... }}
      {{ERROR: No configured Mercurial installation }}
      {{[Thu Sep 21 21:15:36 UTC 2017] Finished branch indexing. Indexing took 19 min }}
      Finished: SUCCESS
       
      It appears that multibranch pipeline uses MercurialSCMSource.retrieve method. The code exempt that I analyzed is below:

       

      try (MercurialSCMSourceRequest request= new MercurialSCMSourceContext<>(criteria, observer).withCredentialsId(credentialsId).withTraits(traits).newRequest(this, listener) ) {

          MercurialInstallation inst = MercurialSCM.findInstallation(request.installation());
          if (inst == null) {
              listener.error("No configured Mercurial installation");
              return;
      {{    }}}

       

      In that code, it appears that the MercurialSCMSourceContext never has "installation" field initialized. MercurialSCMSourceRequest (request) gets its installation from the context, thus it is always null in that trace. The next line MercurialSCM.findInstallation will be called with a null parameter, and it always returns null in that case. It appears that inst is always null and we always get "No configured Mercurial installation", even though we have. 

       

      Attachments

        Activity

          kartal Kartal Tabak added a comment -

          A quick fix without much change would be to alter MercurialSCM.findInstallation. If the parameter of findInstallation is null, then return any mercurial installation. I think this will not violate any contracts of the method. 

          A better fix would be to alter the multibranch pipeline so that mercurial scm accepts installation argument, and pass that configuration to the findInstallation method. I am not that sure whether this modification violates any existing configurations. 

           

          kartal Kartal Tabak added a comment - A quick fix without much change would be to alter MercurialSCM.findInstallation. If the parameter of findInstallation is null, then return any mercurial installation. I think this will not violate any contracts of the method.  A better fix would be to alter the multibranch pipeline so that mercurial scm accepts installation argument, and pass that configuration to the findInstallation method. I am not that sure whether this modification violates any existing configurations.   

          We have a same problem. But in all of the tasks, that uses the resolveScm step. Regardless of the multibranch pipeline. When I write:

          currScm = (MercurialSCM) script.resolveScm([
              ignoreErrors: false,
              source : [
                 $class : 'MercurialSCMSource',
                 branchPattern: '',
                 browser : [
                    $class: 'Kallithea',
                    url : currPrj.repo
                 ],
                 clean : false,
                 credentialsId: '',
                 id : '_',
                 installation : MERCURIAL_SETUP,
                 modules : '',
                 source : currPrj.repo.toString(),
                 subdir : currPrj.name
              ],
              targets : [branch, 'CLIENT', 'default']
          ])

          The build fails with error:

          [Pipeline] resolveScm
          Checking for first existing branch from [default, CLIENT, default]...
          ERROR: No configured Mercurial installation
          Could not find any matching branch%n

          vektory79 Victor Verbitsky added a comment - We have a same problem. But in all of the tasks, that uses the resolveScm step. Regardless of the multibranch pipeline. When I write: currScm = (MercurialSCM) script .resolveScm([     ignoreErrors : false ,     source : [        $class : 'MercurialSCMSource' ,        branchPattern : '' ,        browser : [           $class : 'Kallithea' ,           url : currPrj.repo        ],        clean : false ,        credentialsId : '' ,        id : '_' ,        installation : MERCURIAL_SETUP ,        modules : '' ,        source : currPrj.repo.toString(),        subdir : currPrj.name     ],     targets : [branch, 'CLIENT' , 'default' ] ]) The build fails with error: [Pipeline] resolveScm Checking for first existing branch from [default, CLIENT, default] ... ERROR: No configured Mercurial installation Could not find any matching branch%n
          0y0n Olivier Yon added a comment - - edited

          Hi,

          Maybe not a bug.

          I was facing the same error output but because my project was not properly configured:

          Could you check that in your Multi-branch pipeline "Configure" you have specify the Mercurial Tool installation name?

          "Behaviors" =>  Add => "Select Mercurial Installation"

          Beware the option appears in the combo box only if the options "Use Repository Caches" is check in one of your Mercurial installation from "Manage Jenkins" => "Global Tool Configuration" => "Mercurial installations".

          This option is a must have for multi-branch pipeline and help is not clear enough for new comers like me ( more than two days loose on that, i have to fetch the plugin code to realize how it work...).

          In my humble opinion the Mercurial Installation should not be an optional behavior (because it fails without setting!) but a mandatory field just behind the repository name (like in GIT): This is less error prone. On this field help could explicitly advise that the option is needed. As the behavior it is not present if caching option not selected and so no hint for the user about it...

          In any case thanks to the plugin contributors, I am so happy to see mercurial working with mutli-branch pipeline!

          0y0n Olivier Yon added a comment - - edited Hi, Maybe not a bug. I was facing the same error output but because my project was not properly configured: Could you check that in your Multi-branch pipeline "Configure" you have specify the Mercurial Tool installation name? "Behaviors" =>  Add => "Select Mercurial Installation" Beware the option appears in the combo box only if the options " Use Repository Caches " is check in one of your Mercurial installation from "Manage Jenkins" => " Global Tool Configuration " => "Mercurial installations". This option is a must have for multi-branch pipeline and help is not clear enough for new comers like me ( more than two days loose on that, i have to fetch the plugin code to realize how it work...). In my humble opinion the Mercurial Installation should not be an optional behavior (because it fails without setting!) but a mandatory field just behind the repository name (like in GIT): This is less error prone. On this field help could explicitly advise that the option is needed. As the behavior it is not present if caching option not selected and so no hint for the user about it... In any case thanks to the plugin contributors, I am so happy to see mercurial working with mutli-branch pipeline!
          rrossi Romain Rossi added a comment - - edited

          Thank you 0y0n

          I had the same problem, waiting for a solution. By configuring a Mercurial installation with caches, and selecting it in the pipeline configuration, it now works well.

           

          rrossi Romain Rossi added a comment - - edited Thank you  0y0n I had the same problem, waiting for a solution. By configuring a Mercurial installation with caches, and selecting it in the pipeline configuration, it now works well.  
          kartal Kartal Tabak added a comment -

          Thanks 0y0n

          It should be my mistake. After modifying the Mercurial installation to use repository caches, there "appears" a Mercurial installation selection at "Behaviours -> Add" menu. After the configuration, the build started to scan mercurial. 

          It would be nice to have a documentation stating that, or as suggested by 0y0n "The mercurial installation should be a mandatory field for multi-branch pipeline".

          Having said that, I mark that issue as "Not a Defect" since it appears that the issue is not a defect. 

          kartal Kartal Tabak added a comment - Thanks 0y0n .  It should be my mistake. After modifying the Mercurial installation to use repository caches, there "appears" a Mercurial installation selection at "Behaviours -> Add" menu. After the configuration, the build started to scan mercurial.  It would be nice to have a documentation stating that, or as suggested by 0y0n "The mercurial installation should be a mandatory field for multi-branch pipeline". Having said that, I mark that issue as "Not a Defect" since it appears that the issue is not a defect. 

          People

            Unassigned Unassigned
            kartal Kartal Tabak
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: