如何在Jenkins中的Node配置中获取git标签名称 [英] How to get the git tag name in Jenkins in Node configuration

查看:492
本文介绍了如何在Jenkins中的Node配置中获取git标签名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在Jenkins中使用节点配置.在Post-build Actions中,我们有Git Publisher,它具有要推送的标签,例如5.1.0.$ BUILD_NUMBER.现在成为新的内部版本号,并用作测试的发行版号

We re using node configuration in Jenkins.In the Post-build Actions we have Git Publisher which has tags to Push e.g 5.1.0.$BUILD_NUMBER.This now becomes the new build number and is used as the release number for testing

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

I wanted to access this tag for all the remaining jobs so that I can create the Test report XMLs something with 5.1.0.$BUILD_NUMBER+myjob.xml so that its related to that unique build number.

但是我不确定如何在所有单独的作业中检索Git标签.我不太确定要使用Global variable string属性,因为它是一个节点配置,在一个节点/盒子上存在不同的构建另一个属性则不同.Global属性可以覆盖彼此的构建版本吗?

However I am not sure how can I retrieve the Git tags in all the individual jobs.I am not too sure that I want to use Global variable string property since its a node configuration where on one node/box there a different build and on other there is a different one.The Global property could overwrite the build versions on each other ?

推荐答案

如果要在执行新工作时选择标签,则可以使用

If you want to pick a tag when running a new job, you can use the Git Parameter Plugin. With this plugin you have new options when you add parameters to your job.

此插件允许您将git标签或修订号分配为参数化构建中的参数. 无需进行任何特殊设置,此插件将从Git插件读取您的默认配置.

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.

它首先获取(通过git fetch)当前存储库,并列出所有可供选择的标签/sha1.

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

对于智能变体,比较将数字序列视为单个字符.由Graeme Hill贡献.

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


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


There is also the Git Tag Message Plugin which, for any build, will discover if any tag is matching the current commit used for the build. If a tag is found, it's name will be set in the GIT_TAG_NAME environment variable.

在构建期间将git标签的名称和消息作为环境变量导出.

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

如果在构建期间签出的修订版本具有关联的git标签,则其名称将在构建期间作为GIT_TAG_NAME环境变量导出. 如果在创建标签时指定了一条消息(例如,通过git tag -m"..."),那么该消息也将在构建期间作为GIT_TAG_MESSAGE>环境变量导出.

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.

如果修订具有多个关联的标签,则仅考虑最新的标签.但是,如果您的refspec包含"refs/tags",即-> e.仅当某些标记名称或模式匹配时,才会触发构建-即使触发的构建不是最新的标记,也会使用触发构建的确切标记名称.

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.

这篇关于如何在Jenkins中的Node配置中获取git标签名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆