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

Cannot configure multiple glob fetch refspecs in Git plugin with '*' embedded inside the refspec

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • git-plugin
    • None
    • Jenkins: jenkins/jenkins:2.361.1-jdk11 (in docker)
      Git plugin: 4.11.5

      I am trying to set up refspecs for a project according to this guide, and they specify two glob refspecs to be used:

      +refs/heads/*:refs/remotes/origin/* +refs/merge-requests/*/head:refs/remotes/origin/merge-requests/*
      

      However, I just get a "Specification is invalid" after entering these and cannot proceed.

      Each refspec individually works, just adding them both at the same time does not. Adding two refspecs w/o globs also works.

          [JENKINS-69564] Cannot configure multiple glob fetch refspecs in Git plugin with '*' embedded inside the refspec

          Mark Waite added a comment -

          As far as I can tell, this is not a Jenkins issue. If Gitlab is rejecting the refspecs as invalid, that is likely a Gitlab issue.

          I have confirmed that multiple refpsecs work as expected in Jenkins with my test job JENKINS-69564-multiple-refspecs-freestyle. I have Pipeline jobs that also use multiple refspecs

          You may be able to test the multiple refspecs more quickly from a command line rather than through Jenkins.

          $ mkdir x
          $ cd x
          $ git init
          $ git remote add origin https://github.com/jenkinsci/git-client-plugin.git
          $ git fetch --no-tags origin +refs/heads/*:refs/remotes/origin/* +refs/merge-requests/*/head:refs/remotes/origin/merge-requests/*
          

          Mark Waite added a comment - As far as I can tell, this is not a Jenkins issue. If Gitlab is rejecting the refspecs as invalid, that is likely a Gitlab issue. I have confirmed that multiple refpsecs work as expected in Jenkins with my test job JENKINS-69564-multiple-refspecs-freestyle . I have Pipeline jobs that also use multiple refspecs You may be able to test the multiple refspecs more quickly from a command line rather than through Jenkins. $ mkdir x $ cd x $ git init $ git remote add origin https://github.com/jenkinsci/git-client-plugin.git $ git fetch --no-tags origin +refs/heads/*:refs/remotes/origin/* +refs/merge-requests/*/head:refs/remotes/origin/merge-requests/*

          Mark Waite added a comment -

          It could also be an issue with the version of command line git that is installed on your controller or your agent. As far as I understand it, older versions of command line git do not support wildcards in the refspec that are not in the final position of the string. However, I could be wrong on that.

          You could enable JGit on your Jenkins controller and switch the job to use JGit instead of command line git. That could help narrow the problem to decide if the issue is with the Gitlab server, command line git, or something else.

          Mark Waite added a comment - It could also be an issue with the version of command line git that is installed on your controller or your agent. As far as I understand it, older versions of command line git do not support wildcards in the refspec that are not in the final position of the string. However, I could be wrong on that. You could enable JGit on your Jenkins controller and switch the job to use JGit instead of command line git. That could help narrow the problem to decide if the issue is with the Gitlab server, command line git, or something else.

          Actually I realize that I can apply the two refspecs, and Jenkins then successfully uses them for fetching refs from the remote.

          However, the configure pipeline UI still complains when initially adding the refspecs (local validation I think?).
          After hitting apply anyway and refreshing the configure pipeline page, the error message is no longer displayed and the pipeline works as intended.

          Michael Barton added a comment - Actually I realize that I can apply the two refspecs, and Jenkins then successfully uses them for fetching refs from the remote. However, the configure pipeline UI still complains when initially adding the refspecs (local validation I think?). After hitting apply anyway and refreshing the configure pipeline page, the error message is no longer displayed and the pipeline works as intended.

          Mark Waite added a comment -

          Can you provide more context on the specific location in the UI that rejects the multi-element refspec? I've not seen that warning in any of the locations that I've used, but I've also not checked every page and every path

          Mark Waite added a comment - Can you provide more context on the specific location in the UI that rejects the multi-element refspec? I've not seen that warning in any of the locations that I've used, but I've also not checked every page and every path

          I hope that will clarify the precise location? This is a pipeline project, but freestyle behaves the same..

           

          Michael Barton added a comment - I hope that will clarify the precise location? This is a pipeline project, but freestyle behaves the same..  

          Did you have any chance to look into this some more? Were you able to reproduce the above error on your end?

          Michael Barton added a comment - Did you have any chance to look into this some more? Were you able to reproduce the above error on your end?

          Mark Waite added a comment -

          I didn't investigate any further and probably won't investigate further for at least 6 weeks. Based on the location where you see the message and that I don't see the message when I enter my (different) refspec in that same location, I think it is an issue with the validator not liking that specific refspec. It's a bug in the validator. If you'd like to fix it, you're welcome to submit a pull request.

          Mark Waite added a comment - I didn't investigate any further and probably won't investigate further for at least 6 weeks. Based on the location where you see the message and that I don't see the message when I enter my (different) refspec in that same location, I think it is an issue with the validator not liking that specific refspec. It's a bug in the validator. If you'd like to fix it, you're welcome to submit a pull request.

            Unassigned Unassigned
            emike922 Michael Barton
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: