Skip to content

Instantly share code, notes, and snippets.

@jeffryvu
Created February 12, 2015 20:14
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jeffryvu/e67e21708c0c876a8f0d to your computer and use it in GitHub Desktop.
Save jeffryvu/e67e21708c0c876a8f0d to your computer and use it in GitHub Desktop.
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
@narendramannam
Copy link

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

@saisudhakar
Copy link

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

@vinodakumarsr
Copy link

Its working but format is not same

@kamildziadekpwr
Copy link

Thank you so much for this command! I was not aware that the job can be queried with XPath. I have tweaked it a little bit so that it drops the current build changelog to a variable.

CHANGELOG=$(curl "$BUILD_URL/api/xml?wrapper=changes&xpath=//changeSet//comment" | sed -e "s/<\/comment>//g; s/<comment>/* /g; s/<\/*changes>//g" | sed '/^$/d;G')

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