• git plugin 4.4.0

      When hasGitRepo is false, retrieveChanges() tries firstly to Clone repository and then fetch according to available list of repositories.
      https://github.com/jenkinsci/git-plugin/blob/e9d15cd3a390f1d1849b9d6cbee707bc85213ab0/src/main/java/hudson/plugins/git/GitSCM.java#L1104-L1110
      But when it clones it picks first repository name and injects ALL branches fetch https://github.com/jenkinsci/git-client-plugin/blob/2b217bd90a93462112176febbb5f30e05141c674/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java#L704-L712
      So, when refspecs is empty - it fetch all branches (git default), when it null it fetches all branches.

      The workaround is to set some refspec from branch i.e. https://github.com/jenkinsci/git-plugin/blob/a7ad6eb38a00397c4a656b53d99bfbad8ea3b2cc/src/main/java/jenkins/plugins/git/GitSCMSourceDefaults.java#L108-L115
      But, later it will be fetched anyway.

      Solution:
      Don't fetch anything during clone operation (useful part is clean, fetch etc). OR pass repositories to CloneComand and remove separate fetch iteration .

          [JENKINS-56404] Impossible exclude redundant/double fetches

          Kanstantsin Shautsou created issue -
          Kanstantsin Shautsou made changes -
          Description Original: When hasGitRepo is false retrieveChanges tries firstly to Clone repository and then fetch according to available list of repositories.
          https://github.com/jenkinsci/git-plugin/blob/e9d15cd3a390f1d1849b9d6cbee707bc85213ab0/src/main/java/hudson/plugins/git/GitSCM.java#L1104-L1110
          But when it clones it picks first repository name and injects ALL branches fetch https://github.com/jenkinsci/git-client-plugin/blob/2b217bd90a93462112176febbb5f30e05141c674/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java#L704-L712
          When refspecs is empty - it fetch all branches (git default), when it null it fetches all branches.


          The workaround is to set some refspec from branch i.e. https://github.com/jenkinsci/git-plugin/blob/a7ad6eb38a00397c4a656b53d99bfbad8ea3b2cc/src/main/java/jenkins/plugins/git/GitSCMSourceDefaults.java#L108-L115
          But, later it will be fetched anyway.

          Solution:
          Don't fetch anything during clone operation (useful part is clean, fetch etc). OR pass repositories to CloneComand and remove separate fetch iteration .
          New: When hasGitRepo is false, retrieveChanges() tries firstly to Clone repository and then fetch according to available list of repositories.
          https://github.com/jenkinsci/git-plugin/blob/e9d15cd3a390f1d1849b9d6cbee707bc85213ab0/src/main/java/hudson/plugins/git/GitSCM.java#L1104-L1110
          But when it clones it picks first repository name and injects ALL branches fetch https://github.com/jenkinsci/git-client-plugin/blob/2b217bd90a93462112176febbb5f30e05141c674/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java#L704-L712
          So, when refspecs is empty - it fetch all branches (git default), when it null it fetches all branches.

          The workaround is to set some refspec from branch i.e. https://github.com/jenkinsci/git-plugin/blob/a7ad6eb38a00397c4a656b53d99bfbad8ea3b2cc/src/main/java/jenkins/plugins/git/GitSCMSourceDefaults.java#L108-L115
          But, later it will be fetched anyway.

          Solution:
          Don't fetch anything during clone operation (useful part is clean, fetch etc). OR pass repositories to CloneComand and remove separate fetch iteration .
          Mark Waite made changes -
          Assignee Original: Mark Waite [ markewaite ]
          Kanstantsin Shautsou made changes -
          Priority Original: Minor [ 4 ] New: Critical [ 2 ]
          Mark Waite made changes -
          Link New: This issue is related to JENKINS-49757 [ JENKINS-49757 ]
          Mark Waite made changes -
          Link New: This issue is related to JENKINS-23345 [ JENKINS-23345 ]
          Mark Waite made changes -
          Resolution New: Fixed [ 1 ]
          Status Original: Open [ 1 ] New: Fixed but Unreleased [ 10203 ]
          Mark Waite made changes -
          Released As New: git plugin 4.4.0
          Status Original: Fixed but Unreleased [ 10203 ] New: Closed [ 6 ]

            Unassigned Unassigned
            integer Kanstantsin Shautsou
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: