git - 如何在Node配置中获取Jenkins中的git标签名称

标签 git jenkins nunit

我们在 Jenkins 中使用节点配置。在构建后操作中,我们有 Git Publisher,它具有要推送的标签,例如 5.1.0.$BUILD_NUMBER。这现在成为新的内部版本号,并用作测试的版本号

我想为所有剩余的作业访问此标签,以便我可以使用 5.1.0.$BUILD_NUMBER+myjob.xml 创建测试报告 XML,以便它与该唯一的内部版本号相关。

但是我不确定如何在所有单独的作业中检索 Git 标签。我不太确定是否要使用全局变量字符串属性,因为它是一种节点配置,在一个节点/框中有不同的构建另一方面有一个不同的。Global 属性可以相互覆盖构建版本吗?

最佳答案

如果您想在运行新作业时选择标签,可以使用 Git Parameter Plugin 。有了这个插件,当您向作业添加参数时,您就有了新的选项。

This plugin allows you to assign git tag or revision number as parameter in Parametrized builds. There is no need to set up anything special, this plugin will read your default configuration from Git Plugin.

It firstly fetching (by git fetch) current repository, and listing all the tags/sha1's to choose from.

You can select the following sorting options for tags/revision/branches/branches_or_tags

  • none
  • descending
  • ascending
  • ascending smart
  • descending smart

For the smart variants the compare treats a sequence of digits as a single character. Contributed by Graeme Hill.


还有Git Tag Message Plugin对于任何构建,它将发现是否有任何标签与用于构建的当前提交匹配。如果找到标签,其名称将设置在 GIT_TAG_NAME 环境变量中。

Exports the name and message for a git tag as environment variables during a build.

If the revision checked out during a build has a git tag associated with it, its name will be exported during the build as the GIT_TAG_NAME environment variable. If a message was specified when creating the tag (e.g. via git tag -m "..."), then that message will also be exported during the build, as the GIT_TAG_MESSAGE > environment variable.

If the revision has more than one tag associated with it, only the most recent tag will be taken into account. However, if your refspec includes "refs/tags" — i.> e. builds are only triggered when certain tag names or patterns are matched — then the exact tag name that triggered the build will be used, even if it's not the most recent tag for this commit.

关于git - 如何在Node配置中获取Jenkins中的git标签名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32390788/

相关文章:

git - 如何在 git 中组合多个存储

c# - InlineAutoDataAttribute 但对于 NUnit(对于 TestCase 和 TestCaseSource)

c# - 如何使用 NUnit (C#) 进行通用测试?

git - 有没有办法将 "git blame"的结果输出到文本文件?

git - git merge 时始终使用本地版本的文件(即使 merge 的一侧没有更改)

jenkins - sbt 构建在本地工作但在 Jenkins 上失败

linux - 在 Ubuntu 20.04 上安装 Jenkins 时出错

jenkins - 构建 jenkins Groovy 管道脚本的正确方法

c# - 递归迭代器 block 方法的提前终止

ruby-on-rails - 如何使用 mina 在 Rails 4 应用程序的 deploy.rb 中设置 git?