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

In jenkins pipeline a "checkout scm" now adds "--no-tags" instead of "--tags" for git projects

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Major Major
    • git-plugin
    • None

      I've recently updated a few jenkins plugins and I've noticed that the command that is issued when performing a `checkout scm` in a Jenkins pipeline is adding a `--no-tags` during a the `git fetch` operation, while in the past it was `git fetch --tags`.

      This is preventing our tagging system from working properly.

      Was this change implemented on purpose? Is there a way to pass a param to manually opt-in for the tags?

       

      Thanks,

      Gio

          [JENKINS-45164] In jenkins pipeline a "checkout scm" now adds "--no-tags" instead of "--tags" for git projects

          Yury Zaytsev added a comment -

          Okay, apparently the 'best' way to do it is to replace `checkout scm` with the following little monster:

          checkout([
              $class: 'GitSCM',
              branches: scm.branches,
              doGenerateSubmoduleConfigurations: scm.doGenerateSubmoduleConfigurations,
              extensions: [[$class: 'CloneOption', noTags: false, shallow: false, depth: 0, reference: '']],
              userRemoteConfigs: scm.userRemoteConfigs,
           ])
          

          but you'd need to approve methods as on the attached screenshot to make it work :-/

          Yury Zaytsev added a comment - Okay, apparently the 'best' way to do it is to replace `checkout scm` with the following little monster: checkout([     $class: 'GitSCM' ,     branches: scm.branches,     doGenerateSubmoduleConfigurations: scm.doGenerateSubmoduleConfigurations,     extensions: [[$class: 'CloneOption' , noTags: false , shallow: false , depth: 0, reference: '']],     userRemoteConfigs: scm.userRemoteConfigs, ]) but you'd need to approve methods as on the attached screenshot to make it work :-/

          zaytsev_work: See JENKINS-43507 for a global workaround.

          (Add an "Advanced Clone Behaviours" entry in the branch source behaviors. It can also be set at the Organization/Team-level for GitHub/Bitbucket plugins & co. In that case you'll need to request a re-scan so all sub-jobs are reconfigured appropriately.)

          PS: I'll note we were also a bit upset by this change as it broke dozens of builds for us and since we didn't end up on the original issue immediately we wasted quite some time attempting to reconfigure the projects via the Jenkinsfiles. It seems Yury indeed found the "best" solution with this approach (though we all seem to agree it isn't exactly nice).

          Thibault Nélis added a comment - zaytsev_work : See JENKINS-43507 for a global workaround. (Add an "Advanced Clone Behaviours" entry in the branch source behaviors. It can also be set at the Organization/Team-level for GitHub/Bitbucket plugins & co. In that case you'll need to request a re-scan so all sub-jobs are reconfigured appropriately.) PS: I'll note we were also a bit upset by this change as it broke dozens of builds for us and since we didn't end up on the original issue immediately we wasted quite some time attempting to reconfigure the projects via the Jenkinsfiles. It seems Yury indeed found the "best" solution with this approach (though we all seem to agree it isn't exactly nice).

          Jan Hoppe added a comment -

          This issue and JENKINS-51638 killed my work week. I never had as much issues after a plugin update...

          Jan Hoppe added a comment - This issue and  JENKINS-51638  killed my work week. I never had as much issues after a plugin update...

          Mark Waite added a comment -

          I'm sorry to hear that hoppej.

          I'd love to have additional help with the beta testing of git client plugin 3.0.0 and git plugin 4.0.0. They are available from the experimental update center.

          The Jenkins project gets great benefit from people that actively test beta versions before they are released.

          Mark Waite added a comment - I'm sorry to hear that hoppej . I'd love to have additional help with the beta testing of git client plugin 3.0.0 and git plugin 4.0.0. They are available from the experimental update center . The Jenkins project gets great benefit from people that actively test beta versions before they are released.

          markewaite our central jenkins instance does not allow to add branches.scmbranches. i created JENKINS-56517 as the default option should be "git fetch", not "git fetch --tags" and not "git fetch --no-tags". would be glad if you would know a workaround which gives the tags anyway?

           

          rupert je thurner added a comment - markewaite our central jenkins instance does not allow to add branches.scmbranches. i created  JENKINS-56517  as the default option should be "git fetch", not "git fetch --tags" and not "git fetch --no-tags". would be glad if you would know a workaround which gives the tags anyway?  

          Mark Waite added a comment -

          rthurner as far as I know, an additional behavior is available which will allow you to fetch tags as part of the multibranch pipeline. The branch build strategy plugin adds more capabilities (like building all tags).

          It is an intentional choice to not pull tags by default.

          Mark Waite added a comment - rthurner as far as I know, an additional behavior is available which will allow you to fetch tags as part of the multibranch pipeline. The branch build strategy plugin adds more capabilities (like building all tags). It is an intentional choice to not pull tags by default.

          Jan Hoppe added a comment -

          If anyone knows how to add a fetch --tags in pipeline scripts i spend a beer.

          I am calling "git fetch" in shell script for working builds...

          Jan Hoppe added a comment - If anyone knows how to add a fetch --tags in pipeline scripts i spend a beer. I am calling "git fetch" in shell script for working builds...

          Hey hoppej, you can try to define your scm like this:

          checkout scm: [
              $class: 'GitSCM',
              branches: [[name: "BRANCH_NAME"]],
              userRemoteConfigs: [[credentialsId: "GIT_CREDENTIALS", url: "GIT_REPOSITORY"]]
          ]
          

          Dumitru Gurjui added a comment - Hey hoppej , you can try to define your scm like this: checkout scm: [ $class: 'GitSCM' , branches: [[name: "BRANCH_NAME" ]], userRemoteConfigs: [[credentialsId: "GIT_CREDENTIALS" , url: "GIT_REPOSITORY" ]] ]

          rupert je thurner added a comment - - edited

          currently we use the following workaround to deal with "push -f" to branches, and it still does not work in 100% of the cases. 

          // code placeholder
            checkout([
              $class: 'GitSCM',
              branches: [[name: 'refs/heads/'+env.BRANCH_NAME]],
              extensions: [[$class: 'CloneOption', noTags: false, shallow: false, depth: 0, reference: '']],
              userRemoteConfigs: scm.userRemoteConfigs,
            ])
            sh "git checkout ${env.BRANCH_NAME}"
            sh "git reset --hard origin/${env.BRANCH_NAME}" 
          

          rupert je thurner added a comment - - edited currently we use the following workaround to deal with "push -f" to branches, and it still does not work in 100% of the cases.  // code placeholder checkout([ $class: 'GitSCM' , branches: [[name: 'refs/heads/' +env.BRANCH_NAME]], extensions: [[$class: 'CloneOption' , noTags: false , shallow: false , depth: 0, reference: '']], userRemoteConfigs: scm.userRemoteConfigs, ]) sh "git checkout ${env.BRANCH_NAME}" sh "git reset --hard origin/${env.BRANCH_NAME}"

          the main challenge is that there are 3 possibilities

          • "git fetch" fetches a branch with tags reachable, the ideal default - and jenkins cannot do it at all
          • "git fetch --no-tags" fetches a branch without tags
          • "git fetch --tags" fetches tags not reachable from the branch, i.e. other branches also

          rupert je thurner added a comment - the main challenge is that there are 3 possibilities "git fetch" fetches a branch with tags reachable, the ideal default - and jenkins cannot do it at all "git fetch --no-tags" fetches a branch without tags "git fetch --tags" fetches tags not reachable from the branch, i.e. other branches also

            Unassigned Unassigned
            nemo83 Giovanni Gargiulo
            Votes:
            0 Vote for this issue
            Watchers:
            13 Start watching this issue

              Created:
              Updated:
              Resolved: