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

Git plugin fail to checkout tag

    XMLWordPrintable

    Details

    • Similar Issues:
    • Released As:
      Git plugin 4.6.0

      Description

      I have the following step on a pipeline:

      git url: 'git@gitlab.v.com:v/v-apps-infra/v-apps-infra.git',
                          branch: "vms-r${env.BUILD_ID}"
      

      Plugin fails to check out the tag with the following log:

      Cloning the remote Git repository
      Avoid second fetch
      Cloning repository git@gitlab.v.com:v/v-apps-infra/v-apps-infra.git
       > git init /home/jenkins/agent/workspace/v-apps-app1+PROD # timeout=10
      Fetching upstream changes from git@gitlab.v.com:v/v-apps-infra/v-apps-infra.git
       > git --version # timeout=10
       > git --version # 'git version 2.20.1'
       > git fetch --tags --force --progress -- git@gitlab.v.com:v/v-apps-infra/v-apps-infra.git +refs/heads/*:refs/remotes/origin/* # timeout=10
       > git config remote.origin.url git@gitlab.v.com:v/v-apps-infra/v-apps-infra.git # timeout=10
       > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
       > git rev-parse refs/remotes/origin/app1-r263^{commit} # timeout=10
       > git rev-parse origin/app1-r263^{commit} # timeout=10
      ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job.

      Documentation for pipeline step clearly says tags are supported for the branch parameter:

      Branch to be checked out in the workspace. Default is 'master'.Note that this must be a local branch name like 'master' or 'develop' or a tag name. Remote branch names like 'origin/master' and 'origin/develop' are not supported as the branch argument. SHA-1 hashes are not supported as the branch argument. Remote branch names and SHA-1 hashes are supported by the general purpose checkout step.
      

      But as we can see in the output, the plugin tries to rev-parse the tag name under `refs/remotes/origin/` and `origin/` but does not try `tags/` or just the tag name, which would work.

        Attachments

          Activity

          Hide
          markewaite Mark Waite added a comment - - edited

          Thanks for reporting the error in the documentation for the branch parameter. I've corrected it in PR-1029.

          The branch parameter of the git pipeline step does not accept a tag name. Many other cases are also not supported with the git pipeline step as described in the online help. The checkout step is the preferred Pipeline step for full access to git.

          The documentation previously stated that tag checkout is not supported, but it was showing conflicting information that used tag checkout as an example. Documentation will be corrected in the next release of the git plugin.

          Show
          markewaite Mark Waite added a comment - - edited Thanks for reporting the error in the documentation for the branch parameter. I've corrected it in PR-1029 . The branch parameter of the git pipeline step does not accept a tag name. Many other cases are also not supported with the git pipeline step as described in the online help . The checkout step is the preferred Pipeline step for full access to git. The documentation previously stated that tag checkout is not supported, but it was showing conflicting information that used tag checkout as an example. Documentation will be corrected in the next release of the git plugin.

            People

            Assignee:
            markewaite Mark Waite
            Reporter:
            brunojcm Bruno Medeiros
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: