Instantly share code, notes, and snippets.

Embed
What would you like to do?
Bash script to get the changelog from a certain jenkins build, format it in a nice way and write it to a properties file.
# Based on http://stackoverflow.com/questions/11823826/get-access-to-build-changelog-in-jenkins
# Get changelog and format it properly
CHANGELOG=$(curl "http://localhost:8080/job/MyProject/$UPSTREAM_BUILD_NUMBER/api/xml?wrapper=changes&xpath=//changeSet//comment" | sed -e "s/<\/comment>//g; s/<comment>/* /g; s/<\/*changes>//g" | sed '/^$/d;G')
# Write result to properties file
echo CHANGELOG=$CHANGELOG > build.properties
@adjokovic

This comment has been minimized.

Copy link

adjokovic commented Feb 24, 2015

Thanks for the post. However I am still getting an empty file. I have changed UPSTREAM_BUILD_NUMBER to BUILD_NUMBER, and I have changed local host to the http link to the job ${JOB_URL}${BUILD_NUMBER}. Those are environment variables provided by Jenkins.

The string is located in 'execute shell' portion of the build section of Jenkins, after Xcode executes.

Change log comes back empty. Any suggestion is super helpful. Thanks

@jeffryvu

This comment has been minimized.

Copy link
Owner

jeffryvu commented Apr 2, 2015

Have you tried to just paste the url in a browser and see the result? If you have put this script in a downstream job like I do in the post, you really need to use the UPSTREAM_BUILD_NUMBER, otherwise you're getting the changelog from the current job which is empty.

@narendramannam

This comment has been minimized.

Copy link

narendramannam commented May 23, 2015

how do i conver this properties file to html view only comments and id to show

@saisudhakar

This comment has been minimized.

Copy link

saisudhakar commented Sep 17, 2015

is there a way to get the changelog between a build to the other? Is there an xml exposed by Jenkins?

@vinodakumarsr

This comment has been minimized.

Copy link

vinodakumarsr commented Jul 27, 2018

Its working but format is not same

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment