【问题标题】:Checkout repository based on Tag in the Jenkins Workflow plugin基于 Jenkins Workflow 插件中 Tag 的 Checkout 存储库
【发布时间】:2020-06-27 23:25:36
【问题描述】:

使用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

【问题讨论】:

    标签: jenkins jenkins-workflow


    【解决方案1】:

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

    这是建议的解决方案;

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

    【讨论】:

    • 如果我希望它同时接受分支名称和标签怎么办?
    【解决方案2】:

    这行得通:

    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
    

    【讨论】:

    • 唯一的区别是userRemoteConfigs参数中的]、[
    【解决方案3】:

    noTags: false 可以解决问题。

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

    【讨论】:

      猜你喜欢
      • 2016-06-03
      • 2014-12-25
      • 2021-05-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多