Search code examples
jenkinsjenkins-workflow

Checkout repository based on Tag in the Jenkins Workflow plugin


With the Jenkins Workflow Plugin, I can checkout a repository based on branch. However, I would like to checkout a repository based on a tag.

This is my current configuration for checking out the master branch

node {
    git url: src, branch: 'master'
}

Now I would like to achieve to check out tag 3.6.1. I tried to change the branch to a tag, but that won't work. Neither is there something in the documentation regarding checking out on tag.

Is this currently possible? Am I overseeing something?

references;

https://github.com/jenkinsci/workflow-plugin

https://github.com/jenkinsci/workflow-plugin/blob/master/scm-step/README.md

https://github.com/jenkinsci/workflow-plugin/blob/master/scm-step/src/main/resources/org/jenkinsci/plugins/workflow/steps/scm/GitStep/config.jelly

https://github.com/jenkinsci/workflow-plugin/blob/master/scm-step/src/main/java/org/jenkinsci/plugins/workflow/steps/scm/GitStep.java


Solution

  • Just found the answer myself by crawling through the issue list. Seems like they won't change it; https://issues.jenkins-ci.org/browse/JENKINS-27018

    This is the suggested solution;

    checkout scm: [$class: 'GitSCM', userRemoteConfigs: [[url: src]], branches: [[name: 'refs/tags/3.6.1']]], poll: false