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

Git plugin doesn't use refspec on the first clone/fetch

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • git-plugin
    • None
    • Jenkins ver. 1.649
      Git plugin 2.4.2

      Our repositories have lots of references and we only need to build from a single branch from each job. For example, I have a job with refspec +refs/heads/master:refs/remotes/origin/master.

      On the first clone, it does the following:

      Cloning the remote Git repository
      Using shallow clone
      Avoid fetching tags
      Cloning repository https://github.com/foo.git
      > git init /tmp/jenkins/slave1/workspace/sample/smoke-test # timeout=10
      Fetching upstream changes from https://github.com/foo.git
      > git --version # timeout=10
      > git -c core.askpass=true fetch --no-tags --progress https://github.com/foo.git +refs/heads/*:refs/remotes/origin/* --depth=1 # timeout=10

          [JENKINS-33140] Git plugin doesn't use refspec on the first clone/fetch

          Cuong Tran created issue -
          Cuong Tran made changes -
          Description Original: Our repositories have lots of references and we only need to build from a single branch from each job. For example, I have a job with refspec +refs/heads/master:refs/remotes/origin/master.

          On the first clone, it does the following:

          Cloning the remote Git repository
          Using shallow clone
          Avoid fetching tags
          Cloning repository https://github.com/foo.git
           > git init /tmp/jenkins/slave1/workspace/sample/smoke-test # timeout=10
          Fetching upstream changes from https://github.com/foo.git
           > git --version # timeout=10
           > git -c core.askpass=true fetch --no-tags --progress https://github.com/foo.git +refs/heads/*:refs/remotes/origin/* --depth=1 # timeout=10
          New: Our repositories have lots of references and we only need to build from a single branch from each job. For example, I have a job with refspec +refs/heads/master:refs/remotes/origin/master.

          On the first clone, it does the following:

          Cloning the remote Git repository
          Using shallow clone
          Avoid fetching tags
          Cloning repository https://github.com/foo.git
           > git init /tmp/jenkins/slave1/workspace/sample/smoke-test # timeout=10
          Fetching upstream changes from https://github.com/foo.git
           > git --version # timeout=10
           > git -c core.askpass=true fetch --no-tags --progress https://github.com/foo.git +refs/heads/**:refs/remotes/origin/** --depth=1 # timeout=10
          Mark Waite made changes -
          Assignee Original: Mark Waite [ markewaite ]

          Eugene Timokhov added a comment - Duplicate https://issues.jenkins-ci.org/browse/JENKINS-31393
          Eugene Timokhov made changes -
          Resolution New: Duplicate [ 3 ]
          Status Original: Open [ 1 ] New: Closed [ 6 ]

          Mark Waite added a comment -

          Fixed in git plugin 2.5.1

          Mark Waite added a comment - Fixed in git plugin 2.5.1
          R. Tyler Croy made changes -
          Workflow Original: JNJira [ 169013 ] New: JNJira + In-Review [ 209746 ]

          Hey,

          I'm getting the same exactly bug with version 3.0.5 and Jenkins: 2.32.2.

          The steps to reproduce the issue are the same.

          Is it possible to have a regression here?

          Thanks.

          Javier Agüera added a comment - Hey, I'm getting the same exactly bug with version 3.0.5 and Jenkins: 2.32.2. The steps to reproduce the issue are the same. Is it possible to have a regression here? Thanks.
          Javier Agüera made changes -
          Resolution Original: Duplicate [ 3 ]
          Status Original: Closed [ 6 ] New: Reopened [ 4 ]

          Mark Waite added a comment -

          What you're seeing is not a regression. It is an intentional choice that the default behavior had to remain compatible with the behavior which caused this bug report and JENKINS-31393.

          One or more use cases depended on the bug that the default initial fetch retrieved all refspecs, even if a refspec was provided. I was unable to find any way to make those use cases work other than to leave the default behavior as it was before this bug was fixed.

          Users who need to honor the refspec on initial clone will need to modify their job definition to add that to the job definition. The "Advanced clone behaviours" available in the "Add" button of the git plugin configuration section now includes a check box "Honor refspec on initial clone". You need to check that box for all jobs where you want to honor refspec on initial clone.

          Mark Waite added a comment - What you're seeing is not a regression. It is an intentional choice that the default behavior had to remain compatible with the behavior which caused this bug report and JENKINS-31393 . One or more use cases depended on the bug that the default initial fetch retrieved all refspecs, even if a refspec was provided. I was unable to find any way to make those use cases work other than to leave the default behavior as it was before this bug was fixed. Users who need to honor the refspec on initial clone will need to modify their job definition to add that to the job definition. The "Advanced clone behaviours" available in the "Add" button of the git plugin configuration section now includes a check box "Honor refspec on initial clone". You need to check that box for all jobs where you want to honor refspec on initial clone.
          Mark Waite made changes -
          Link New: This issue is related to JENKINS-31393 [ JENKINS-31393 ]
          Mark Waite made changes -
          Resolution New: Fixed [ 1 ]
          Status Original: Reopened [ 4 ] New: Resolved [ 5 ]

            Unassigned Unassigned
            ctran Cuong Tran
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: