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

Jenkins Git plugin only checks out tags on existing repository

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • git-plugin
    • Jenkins 2.319.3
      org.jenkins-ci.main:jenkins-war:2.319.3
      org.jenkins-ci.plugins:git-client:3.11.0
      org.jenkins-ci.plugins:git:4.10.3

      git version 2.35

      When specifying tag checkout behaviour explicitly in the git plugin, tags are only checked out if the workspace already exists and contains a git repository.

      Reproduce by creating a git repository containing the following Jenkinsfile:

      pipeline {
          agent any
          options { skipDefaultCheckout(true) }
          triggers { githubPush() }
          stages {
              stage('Clone repository') {
                  steps {
                      cleanWs()
                      checkout([
                          $class: 'GitSCM',
                          branches: scm.branches,
                          doGenerateSubmoduleConfigurations: scm.doGenerateSubmoduleConfigurations,
                          extensions: scm.extensions + [[$class: 'CloneOption', noTags: false, reference: '', shallow: false]],
                          submoduleCfg: [],
                          userRemoteConfigs: scm.userRemoteConfigs
                      ])
                      checkout([
                          $class: 'GitSCM',
                          branches: scm.branches,
                          doGenerateSubmoduleConfigurations: scm.doGenerateSubmoduleConfigurations,
                          extensions: scm.extensions + [[$class: 'CloneOption', noTags: false, reference: '', shallow: false]],
                          submoduleCfg: [],
                          userRemoteConfigs: scm.userRemoteConfigs
                      ])
                  }
              }
          }
      }
      

       and you will see this happens in the build log - I have attached the full build log for reference:

      10:47:01   > /usr/bin/git fetch --no-tags --force --progress -- https://github.com/ilCatania/jenkins-git-no-tags.git +refs/heads/master:refs/remotes/origin/master # timeout=10
      10:47:02   > /usr/bin/git fetch --tags --force --progress -- https://github.com/ilCatania/jenkins-git-no-tags.git +refs/heads/master:refs/remotes/origin/master # timeout=10
      

          [JENKINS-67984] Jenkins Git plugin only checks out tags on existing repository

          Gabriele Catania created issue -
          Gabriele Catania made changes -
          Environment Original: Jenkins 2.319.3
          org.jenkins-ci.main:jenkins-war:2.319.3
          org.jenkins-ci.plugins:git-client:3.11.0
          org.jenkins-ci.plugins:git:4.10.3
          New: Jenkins 2.319.3
          org.jenkins-ci.main:jenkins-war:2.319.3
          org.jenkins-ci.plugins:git-client:3.11.0
          org.jenkins-ci.plugins:git:4.10.3

          git version 2.35
          Gabriele Catania made changes -
          Link New: This issue relates to JENKINS-45164 [ JENKINS-45164 ]

          To clarify, I've marked the severity as major because several versioning schemes use existing tags to calculate CI/CD build versions, and they calculate the wrong version if no tags are checked out.
          It took me several hours to troubleshoot this issue after noticing my build artifact versions were calculated incorrectly. I would imagine others will be similarly impacted.
          For examples of versioning tools broken by this bug: jgitver (maven/gradle), setuptools_scm (python), sbt-git-versioning (scala)

          Gabriele Catania added a comment - To clarify, I've marked the severity as major because several versioning schemes use existing tags to calculate CI/CD build versions, and they calculate the wrong version if no tags are checked out. It took me several hours to troubleshoot this issue after noticing my build artifact versions were calculated incorrectly. I would imagine others will be similarly impacted. For examples of versioning tools broken by this bug: jgitver (maven/gradle), setuptools_scm (python), sbt-git-versioning (scala)

          markewaite can you please confirm you're able to reproduce the issue? Do you have any pointers on how to fix please?

          Gabriele Catania added a comment - markewaite can you please confirm you're able to reproduce the issue? Do you have any pointers on how to fix please?

          Mark Waite added a comment -

          ilcatania I am out of the office spending time with family. I won't investigate this until the middle of next week at the earliest.

          Mark Waite added a comment - ilcatania I am out of the office spending time with family. I won't investigate this until the middle of next week at the earliest.

          markewaite ok thank you for replying back. If any more info is needed or this should be assigned to someone else please let me know.

          Gabriele Catania added a comment - markewaite ok thank you for replying back. If any more info is needed or this should be assigned to someone else please let me know.

          Hi, any news on this one please? Would appreciate pointers on how to solve, thank you very much

          Gabriele Catania added a comment - Hi, any news on this one please? Would appreciate pointers on how to solve, thank you very much

          markewaite can you help with this? Or can you point me to someone who can please? Thanks

          Gabriele Catania added a comment - markewaite can you help with this? Or can you point me to someone who can please? Thanks
          Gabriele Catania made changes -
          Rank New: Ranked higher

            Unassigned Unassigned
            ilcatania Gabriele Catania
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: