Skip to content

Instantly share code, notes, and snippets.

@tterrag1098
Forked from matthewprenger/changelog-auth.gradle
Last active August 29, 2015 14:28
Show Gist options
  • Save tterrag1098/b73ea2ae85215efac38a to your computer and use it in GitHub Desktop.
Save tterrag1098/b73ea2ae85215efac38a 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
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment