How do i add git fetch tags in a declarative jenkins pipeline script

Viewed 2775

I am fairly new with Jenkins and Git and I am still trying to figure out how to use the jenkins declarative pipeline script. I also have very minimal programming background so the groovy script is a bit new to me.

In my declarative pipeline script, I want to be able to fetch all of my git tags and descriptions while pulling the repository in the jenkins build process.

Currently what i have is this:

stage ('get_repo') {
    checkout([$class: 'GitSCM', 
        branches: [[name: '*/rc']], 
        doGenerateSubmoduleConfigurations: false, 
        extensions: [], 
        submoduleCfg: [], 
        userRemoteConfigs: [[credentialsId: 'git',
                             url: 'git@bitbucket.org:myrepo/myrepo.git']]])
}

I am not sure what I should add. Thanks in advance!

1 Answers

Try using this one

checkout([$class: 'GitSCM',
      branches: [[name: '*/master']],
      doGenerateSubmoduleConfigurations: false,
      extensions: [[$class: 'CloneOption',
               depth: 0,
               **noTags**: **false**,
               reference: '', shallow: false]],
      submoduleCfg: [],
      userRemoteConfigs: [[]]]
)
Related