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

Allow to customize refspec/tags of the clone/fetch commands

    • Icon: New Feature New Feature
    • Resolution: Fixed
    • Icon: Major Major
    • git-client-plugin
    • None

      When using custom refspecs, we may not want to fetch the usual refs/heads/:refs/remotes/<remote>/ that is usually fetched when cloning a repository.

      Also, for repositories that contain a lot of tags, it may not be interesting to fetch tags in a CI job, as what is usually needed is one branch's head.

          [JENKINS-26417] Allow to customize refspec/tags of the clone/fetch commands

          Code changed in jenkins
          User: Vincent LATOMBE
          Path:
          src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java
          src/main/java/org/jenkinsci/plugins/gitclient/CloneCommand.java
          src/main/java/org/jenkinsci/plugins/gitclient/FetchCommand.java
          src/main/java/org/jenkinsci/plugins/gitclient/JGitAPIImpl.java
          src/test/java/org/jenkinsci/plugins/gitclient/GitAPITestCase.java
          http://jenkins-ci.org/commit/git-client-plugin/1a5f40df2473cc3c05e4bb8fc177631a440e3b0f
          Log:
          JENKINS-26417 Allow customization of refspec/tags of the clone/fetch commands

          • Add the option to omit tags to FetchCommand and CloneCommand
          • Allow use of custom refspecs for CloneCommand

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Vincent LATOMBE Path: src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java src/main/java/org/jenkinsci/plugins/gitclient/CloneCommand.java src/main/java/org/jenkinsci/plugins/gitclient/FetchCommand.java src/main/java/org/jenkinsci/plugins/gitclient/JGitAPIImpl.java src/test/java/org/jenkinsci/plugins/gitclient/GitAPITestCase.java http://jenkins-ci.org/commit/git-client-plugin/1a5f40df2473cc3c05e4bb8fc177631a440e3b0f Log: JENKINS-26417 Allow customization of refspec/tags of the clone/fetch commands Add the option to omit tags to FetchCommand and CloneCommand Allow use of custom refspecs for CloneCommand

          Code changed in jenkins
          User: Vincent LATOMBE
          Path:
          src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java
          src/test/java/org/jenkinsci/plugins/gitclient/GitAPITestCase.java
          http://jenkins-ci.org/commit/git-client-plugin/ada4ade93e2f19ec9e788eb1fa862e1dd54820ee
          Log:
          JENKINS-26417 Add a unit test for clone with multiple refspecs

          Rolling back the change to #getBranches()

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Vincent LATOMBE Path: src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java src/test/java/org/jenkinsci/plugins/gitclient/GitAPITestCase.java http://jenkins-ci.org/commit/git-client-plugin/ada4ade93e2f19ec9e788eb1fa862e1dd54820ee Log: JENKINS-26417 Add a unit test for clone with multiple refspecs Rolling back the change to #getBranches()

          Mark Waite added a comment -

          Included in the git-client-plugin master branch, will be in the next release of the git-client-plugin after 1.15.0

          Mark Waite added a comment - Included in the git-client-plugin master branch, will be in the next release of the git-client-plugin after 1.15.0

          Mark Waite added a comment -

          Released as git-client-plugin 1.16.1

          Mark Waite added a comment - Released as git-client-plugin 1.16.1

          Daniel Geißler added a comment - - edited

          As far as i can see the refspec is not used on the initial clone.

          Here is the relevant extract from a build with a cleaned workspace:

          Cloning the remote Git repository
          Cloning repository gitserver:/data/git/MyProject.git
           > /usr/bin/git init /data/jenkins/workspace/myjob.checkoutrefspec # timeout=10
          Fetching upstream changes from gitserver:/data/git/MyProject.git
           > /usr/bin/git --version # timeout=10
          using GIT_SSH to set credentials Jenkins private key
           > /usr/bin/git fetch --tags --progress gitserver:/data/git/MyProject.git +refs/heads/*:refs/remotes/origin/*
           > /usr/bin/git config remote.origin.url gitserver:/data/git/MyProject.git # timeout=10
           > /usr/bin/git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
           > /usr/bin/git config remote.origin.url gitserver:/data/git/MyProject.git # timeout=10
          

          this is directly followed by

           
          Fetching upstream changes from gitserver:/data/git/MyProject.git
          using GIT_SSH to set credentials Jenkins private key
           > /usr/bin/git fetch --tags --progress gitserver:/data/git/MyProject.git +refs/heads/development:refs/remotes/origin/development
           > /usr/bin/git rev-parse origin/development^{commit} # timeout=10
          Checking out Revision c5280c05a01a61f2ae43e46a1ee398be27cdc14e (origin/development)
           > /usr/bin/git config core.sparsecheckout # timeout=10
           > /usr/bin/git checkout -f c5280c05a01a61f2ae43e46a1ee398be27cdc14e
          First time build. Skipping changelog.
          

          wich is the same for later Builds.

          I tested with:

          • Jenkins Latest and greatest (1.614)
          • Jenkins Older but stable (1.596.3)
          • git-client 1.17.1
          • git-client 1.16.1
          • Git plugin 2.3.5 and 2.3.4

          Anyone can confirm this?

          We have some old and heavy branches (with some binaries) that we do not want to get fetched at any time. As of today this is only possible with sparse checkouts, but they have the drawback that we can not push tags back to remote after the build.

          Hope this is the right place, or should that be reported to the git plugin?

          Daniel Geißler added a comment - - edited As far as i can see the refspec is not used on the initial clone. Here is the relevant extract from a build with a cleaned workspace: Cloning the remote Git repository Cloning repository gitserver:/data/git/MyProject.git > /usr/bin/git init /data/jenkins/workspace/myjob.checkoutrefspec # timeout=10 Fetching upstream changes from gitserver:/data/git/MyProject.git > /usr/bin/git --version # timeout=10 using GIT_SSH to set credentials Jenkins private key > /usr/bin/git fetch --tags --progress gitserver:/data/git/MyProject.git +refs/heads/*:refs/remotes/origin/* > /usr/bin/git config remote.origin.url gitserver:/data/git/MyProject.git # timeout=10 > /usr/bin/git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10 > /usr/bin/git config remote.origin.url gitserver:/data/git/MyProject.git # timeout=10 this is directly followed by Fetching upstream changes from gitserver:/data/git/MyProject.git using GIT_SSH to set credentials Jenkins private key > /usr/bin/git fetch --tags --progress gitserver:/data/git/MyProject.git +refs/heads/development:refs/remotes/origin/development > /usr/bin/git rev-parse origin/development^{commit} # timeout=10 Checking out Revision c5280c05a01a61f2ae43e46a1ee398be27cdc14e (origin/development) > /usr/bin/git config core.sparsecheckout # timeout=10 > /usr/bin/git checkout -f c5280c05a01a61f2ae43e46a1ee398be27cdc14e First time build. Skipping changelog. wich is the same for later Builds. I tested with: Jenkins Latest and greatest (1.614) Jenkins Older but stable (1.596.3) git-client 1.17.1 git-client 1.16.1 Git plugin 2.3.5 and 2.3.4 Anyone can confirm this? We have some old and heavy branches (with some binaries) that we do not want to get fetched at any time. As of today this is only possible with sparse checkouts, but they have the drawback that we can not push tags back to remote after the build. Hope this is the right place, or should that be reported to the git plugin?

          Vincent Latombe added a comment - - edited

          It is a different issue, please open a separate ticket on the git plugin

          Vincent Latombe added a comment - - edited It is a different issue, please open a separate ticket on the git plugin

            ndeloof Nicolas De Loof
            vlatombe Vincent Latombe
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: