-
-
Save jeffryvu/e67e21708c0c876a8f0d to your computer and use it in GitHub Desktop.
# 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 |
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.
how do i conver this properties file to html view only comments and id to show
is there a way to get the changelog between a build to the other? Is there an xml exposed by Jenkins?
Its working but format is not same
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')
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