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

          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: