Skip to content

Instantly share code, notes, and snippets.

@matthewprenger
Last active July 5, 2016 11:12
Show Gist options
  • Save matthewprenger/e13d1a4e47ccb5c920a9 to your computer and use it in GitHub Desktop.
Save matthewprenger/e13d1a4e47ccb5c920a9 to your computer and use it in GitHub Desktop.
Jenkins Gradle Changelog Init Script, place this in ~/.gradle/init.d/changelog.gradle on your Jenkins server. Projects can simply call 'project.changelog' to get the changes for the current build.
def buildUrl = System.getenv().BUILD_URL
if (buildUrl != null) {
def auth = "<USER>:<APITOKEN>".getBytes().encodeBase64().toString()
def url = new URL("$buildUrl/api/xml?depth=20").openConnection()
url.setRequestProperty("Authorization", "Basic " + auth)
String data = url.getInputStream().text
def changelog = ""
def xml = new XmlSlurper().parseText(data)
xml.changeSet.item.each { change ->
changelog += "$change.author.fullName: $change.msg" + '\n'
}
allprojects {
project.ext.changelog = changelog
}
}
def buildUrl = System.getenv().BUILD_URL
if (buildUrl != null) {
def url = new URL("$buildUrl/api/xml?depth=20").openConnection()
String data = url.getInputStream().text
def changelog = ""
def xml = new XmlSlurper().parseText(data)
xml.changeSet.item.each { change ->
changelog += "$change.author.fullName: $change.msg" + '\n'
}
allprojects {
project.ext.changelog = changelog
}
}
@hanetzer
Copy link

noice, keeping this for future reference

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