Jenkins Workflow 插件中基于 Tag 的 Checkout 存储库

Checkout repository based on Tag in the Jenkins Workflow plugin

使用 Jenkins Workflow Plugin,我可以根据分支签出存储库。但是,我想根据标签签出存储库。

这是我当前检查主分支的配置

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

现在我想实现签出标签3.6.1。我试图将分支更改为标签,但这行不通。文档中也没有关于签出标签的内容。

目前可以吗?我在监督什么吗?

参考文献;

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

刚刚自己通过浏览问题列表找到了答案。似乎他们不会改变它; https://issues.jenkins-ci.org/browse/JENKINS-27018

这是建议的解决方案;

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

这个有效:

checkout scm: [$class: 'GitSCM', userRemoteConfigs: [[url: repoURL, 
credentialsId: credential]], branches: [[name: tag-version]]],poll: false

不是这个:

checkout scm: [$class: 'GitSCM', userRemoteConfigs: [[url: repoURL], 
[credentialsId: credential]], branches: [[name: tag-version]]],poll: false

noTags: false 成功了。

checkout([$class: 'GitSCM', branches: [[name: githash ]],
     doGenerateSubmoduleConfigurations: false, 
     extensions: [[$class: 'CloneOption', 
     depth: 0, 
     noTags: false,