获得对Jenkins中的Build Changelog的访问 [英] Get access to Build Changelog in Jenkins

查看:581
本文介绍了获得对Jenkins中的Build Changelog的访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在努力寻找一种方法,以将Jenkins生成的更改列表(从SVN拉出)包括到我们的Testflight注释中.我正在使用Testflight插件,该插件具有用于注释的字段-但jenkins似乎并没有嵌入该信息的任何参数/令牌.

I've been pulling my hair out trying to find a way to include the list of changes generated by Jenkins (from the SVN pull) into our Testflight notes. I'm using the Testflight Plugin, which has a field for notes - but there doesn't seem to be any paramater/token that jenkins creates to embed that information.

有人有幸完成这样的事情吗?

Has anyone had any luck accomplishing something like this?

推荐答案

TestFlight插件似乎将变量扩展到构建说明"字段中,因此问题是:我们如何才能将当前构建的更改获取到一个环境变量?

It looks like the TestFlight Plugin expands variables placed into the "Build Notes" field, so the question is: how can we get the changes for the current build into an environment variable?

据我所知,Subversion插件没有通过环境变量提供此信息.但是,所有Jenkins SCM插件都集成了变更日志信息,如您通过Web UI中每个构建版本的变更"链接所看到的.

As far as I'm aware, the Subversion plugin doesn't provide this information via an environment variable. However, all Jenkins SCM plugins integrate changelog information, as you can see via the "Changes" link in the web UI for each build.

即使正在进行构建,也可以通过Jenkins API获得此信息.

This information is also available via the Jenkins API, even while a build is in progress.

例如,如果您在运行此命令的位置添加执行外壳"构建步骤:

For example, if you add an "Execute shell" build step where you run this command:

curl -s "http://jenkins/job/my-job/$BUILD_NUMBER/api/xml?wrapper=changes&xpath=//changeSet//comment"

您将获得类似于以下内容的XML文档:

You'll get an XML document similar to this:

<changes>
  <comment>First commit.</comment>
  <comment>Second commit.</comment>
</changes>

然后,您可以根据自己的喜好设置此信息的格式,并将其放入环境变量中,然后可以在TestFlight的构建说明"部分中进行引用.

You can then format this information however you like and place it into an environment variable which can then be referenced in the TestFlight "Build Notes" section.

但是,默认情况下,在构建步骤中设置环境变量不是永久性的—为此,需要使用 EnvInject插件.

However, setting an environment variable in a build step isn't persistent by default — to do so requires using the EnvInject Plugin.

在这种情况下,您可以将变更日志文本写入具有以下内容的临时文件:

In this case, you could write your changelog text to a temporary file with contents like:

CHANGELOG="New in this build:\n- First commit.\n- Second commit."

然后,通过对环境属性文件使用构建步骤路径选项以加载该文件,$CHANGELOG变量将在您的环境中存在并持续到构建结束,从而允许您在构建说明"字段中使用它.

Then, by using a build step with the Environment Properties File Path option to load this file, the $CHANGELOG variable would exist in your environment and persist until the end of the build, allowing you to use it in the "Build Notes" field.

注意::我自己没有使用TestFlight插件(尽管我快速浏览了代码),并且仅使用Git存储库测试了更改API.同样,我也没有测试应如何使用EnvInject插件编码换行符,否则可能会引起问题.

Note: I haven't used the TestFlight plugin myself (though I took a quick look at the code), and I only tested the changes API with a Git repository. Similarly, I didn't test how newlines should be encoded with the EnvInject plugin, so that could cause issues.

这篇关于获得对Jenkins中的Build Changelog的访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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