Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
837 views
in Technique[技术] by (71.8m points)

svn - Get access to Build Changelog in 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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?

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.

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"

You'll get an XML document similar to this:

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

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.

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."

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.


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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...