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

Pipeline Branch Specifier "blank for 'any'" fails

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • git-plugin
    • Jenkins ver. 2.60.3 and 2.73.1

      In Pipeline Job, "Branches to build configuration" it's said "blanck for any" but it fails when I manually trigger the build with :
      java.lang.IllegalArgumentException: Invalid refspec refs/heads/**
      see screen shots for more details

      is there any other way to build all branches?

      Work around the issue by disabling lightweight checkout in the job definition

          [JENKINS-46588] Pipeline Branch Specifier "blank for 'any'" fails

          Adrien Lecharpentier added a comment - - edited

          flopic it would be interested to have a support-bundle of your instance so we can see the git-plugin version you are using. It would greatly help to reproduce the issue.

          Support bundle are generated using Support Core plugin

          Adrien Lecharpentier added a comment - - edited flopic it would be interested to have a support-bundle of your instance so we can see the git-plugin version you are using. It would greatly help to reproduce the issue. Support bundle are generated using Support Core plugin

          I'm seeing the same issue, also with jenkins 2.60.3. Git plugin is current:

           

          * git:3.5.1 'Jenkins Git plugin'
          * git-client:2.5.0 'Jenkins Git client plugin'
          * git-server:1.7 'Jenkins GIT server Plugin'
          

          I can attach a support bundle if it helps. Still looking through it to see what it contains.

          Nathaniel Irons added a comment - I'm seeing the same issue, also with jenkins 2.60.3. Git plugin is current:   * git:3.5.1 'Jenkins Git plugin' * git-client:2.5.0 'Jenkins Git client plugin' * git-server:1.7 'Jenkins GIT server Plugin' I can attach a support bundle if it helps. Still looking through it to see what it contains.

          Flo Pic added a comment -

          I have the same Jenkins/Git plugin versions as Nathaniel Irons :

          • git : 3.5.1 'Jenkins Git plugin'
          • git-client : 2.5.0 'Jenkins Git client plugin'
          • git-server : 1.7 'Jenkins GIT server Plugin'

          Flo Pic added a comment - I have the same Jenkins/Git plugin versions as Nathaniel Irons : git : 3.5.1 'Jenkins Git plugin' git-client : 2.5.0 'Jenkins Git client plugin' git-server : 1.7 'Jenkins GIT server Plugin'

          This appears to be 100% reproducible on 2.60.3. With a single branch specifier for a project hosted at github, if I leave the branch specifier field blank and save the job, Jenkins will fill the field with two asterisks. Kicking off a build at that point fails, with the error:

          Invalid refspec refs/heads/**

          However, when I update to 2.70.1, the same manually invoked build with a branch specifier of "**" now says "Multiple candidate revisions" and seems to pick a branch at random. This seems closer to expected behavior, though I'd like to understand how it's making a choice.

           

           

          Nathaniel Irons added a comment - This appears to be 100% reproducible on 2.60.3. With a single branch specifier for a project hosted at github, if I leave the branch specifier field blank and save the job, Jenkins will fill the field with two asterisks. Kicking off a build at that point fails, with the error: Invalid refspec refs/heads/** However, when I update to 2.70.1, the same manually invoked build with a branch specifier of "**" now says "Multiple candidate revisions" and seems to pick a branch at random. This seems closer to expected behavior, though I'd like to understand how it's making a choice.    

          Well, it was working for me four hours ago, but now I'm reproducing the invalid refspec error, in 2.70.1, in response to both polled changes and when invoking builds manually. The only branch specifier syntax I can find that reliably succeeds is some kind of specific branch prefix.

          Nathaniel Irons added a comment - Well, it was working for me four hours ago, but now I'm reproducing the invalid refspec error, in 2.70.1, in response to both polled changes and when invoking builds manually. The only branch specifier syntax I can find that reliably succeeds is some kind of specific branch prefix.

          Nathaniel Irons added a comment - - edited

          Sorry, both of my above references to 2.70.1 were from memory, and should have been 2.73.1, the current LTS.

          Nathaniel Irons added a comment - - edited Sorry, both of my above references to 2.70.1 were from memory, and should have been 2.73.1, the current LTS.

          Mark Waite added a comment -

          I can duplicate the error you're seeing. Using a simple pipeline (not multi-branch) and leaving the "branches to build" field empty, the pipeline clone attempts to use an invalid refspec.

          The "blank for any" default does not make sense in the context of a simple (non multi-branch) pipeline job. It is a legacy from the freestyle project where a single job was allowed to switch from one branch to another. A simple pipeline is intended to build a single branch, not to switch back and forth between branches.

          If you want to build multiple branches with pipeline, use the multi-branch pipeline job. It will discover new branches, remove jobs for old branches, and maintain a usable history for the branches, because it maintains one job per branch.

          Mark Waite added a comment - I can duplicate the error you're seeing. Using a simple pipeline (not multi-branch) and leaving the "branches to build" field empty, the pipeline clone attempts to use an invalid refspec. The "blank for any" default does not make sense in the context of a simple (non multi-branch) pipeline job. It is a legacy from the freestyle project where a single job was allowed to switch from one branch to another. A simple pipeline is intended to build a single branch, not to switch back and forth between branches. If you want to build multiple branches with pipeline, use the multi-branch pipeline job. It will discover new branches, remove jobs for old branches, and maintain a usable history for the branches, because it maintains one job per branch.

          Flo Pic added a comment - - edited

          That's what i've done (going on multibranch)!

          The backup solution if you really want : "*/*" for checking all branches and just build the last changed.

          My "real" problem was to have a wrong advise "blank for any"

           

          Flo Pic added a comment - - edited That's what i've done (going on multibranch)! The backup solution if you really want : "* / *" for checking all branches and just build the last changed. My "real" problem was to have a wrong advise "blank for any"  

          Mark Waite added a comment -

          I agree flopic, the advice "blank for any" is wrong in that context. As far as I can tell, a wild card is also wrong in that context. It works when I select a single branch, but fails when I enter a wildcard (like maste*), it fails with a null pointer exception.

          Mark Waite added a comment - I agree flopic , the advice "blank for any" is wrong in that context. As far as I can tell, a wild card is also wrong in that context. It works when I select a single branch, but fails when I enter a wildcard (like maste* ), it fails with a null pointer exception.

          Dave Cobb added a comment -

          Is there a workaround for this other than specifying a branch name?

          Dave Cobb added a comment - Is there a workaround for this other than specifying a branch name?

          Mark Waite added a comment -

          No mndavec, the only solution is to specify the name of the branch to be built.

          When the branch name is known in the context of a multi-branch Pipeline, it is set as BRANCH_NAME as described in stackoverflow. More detail is available in the comments of JENKINS-30252.

          Mark Waite added a comment - No mndavec , the only solution is to specify the name of the branch to be built. When the branch name is known in the context of a multi-branch Pipeline, it is set as BRANCH_NAME as described in stackoverflow . More detail is available in the comments of JENKINS-30252 .

          Jorge Sivil added a comment -

          I had the same problem, but for this you have to use another type of project "Multibranch Pipeline" instead of "Pipeline"

           

          Jorge Sivil added a comment - I had the same problem, but for this you have to use another type of project "Multibranch Pipeline" instead of "Pipeline"  

          Ivan Morgun added a comment -

          "Lightweight checkout" checkbox causes this issue. If you uncheck it everything will work.

          Just for temp workaround.

          Ivan Morgun added a comment - "Lightweight checkout" checkbox causes this issue. If you uncheck it everything will work. Just for temp workaround.

          mark sweeney added a comment - - edited

          Using * / * works for me (remove the spaces so it is star/star, without the spaces the editor keeps converting it to a bold slash).

          Using a 'blank' as suggested by Jenkins reverts to ** being entered – which always failed with java.lang.IllegalArgumentException: Invalid refspec refs/heads/**

          mark sweeney added a comment - - edited Using * / * works for me (remove the spaces so it is star/star, without the spaces the editor keeps converting it to a bold slash). Using a 'blank' as suggested by Jenkins reverts to ** being entered – which always failed with java.lang.IllegalArgumentException: Invalid refspec refs/heads/**

            Unassigned Unassigned
            flopic Flo Pic
            Votes:
            7 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated: