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

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

问题描述

我一直在努力寻找一种方法将 Jenkins 生成的更改列表(来自 SVN pull)包含到我们的 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 Plugin 扩展了放置在Build Notes"字段中的变量,所以问题是:我们如何将当前构建的更改放入环境变量?

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.

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

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:
- First commit.
- Second commit."

然后,通过使用带有 环境属性文件的构建步骤Path 选项加载此文件,$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天全站免登陆