I am trying git checkout in Jenkinsfile following way
stage ('Repo Checkout') {
steps {
dir('My-Repo') {
git branch: '${BUILD_BRANCH}',
credentialsId: 'jenkins',
url: '[email protected]:my-org/my-repo.git'
}
}
}
Is there a way to checkout specific tag in Jenkinsfile ?
Try this.
stage('CheckOut code from git tag') {
checkout([$class: 'GitSCM', branches: [[name: "refs/tags/v3.0"]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'SubmoduleOption', disableSubmodules: false, parentCredentials: false, recursiveSubmodules: false, reference: '', trackingSubmodules: false]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: "gitlab-ssh-user", url: "[email protected]:xxxx/xxxxx.git"]]])
}
Here I am checking out tag v3.0 and in case you want to checkout any branch just mention */branch_name
NOTE: This will work in both scripted and declarative pipeline.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With