Skip to content

Instantly share code, notes, and snippets.

@yogeshlonkar
Last active October 26, 2018 13:41
Show Gist options
  • Save yogeshlonkar/dfc61ee1ea1f42c746940666b350065b to your computer and use it in GitHub Desktop.
Save yogeshlonkar/dfc61ee1ea1f42c746940666b350065b to your computer and use it in GitHub Desktop.
Jenkins currentBuild getChangeLog as a string
@NonCPS
def getChangeLog(currentBuild) {
def changeLogSets = currentBuild.changeSets
def changeLogToReturn = ''
currentBuild
.changeSets
.each { changeLogSet ->
changeLogSet.items.each { changeSet ->
def commmitDate = new Date().format("EEE MMM dd yy HH:mm:ss", TimeZone.getTimeZone('GMT+5:30'))
changeLogToReturn += "<${changeLogSet.browser.repoUrl}commit/${changeSet.commitId}|${changeSet.msg}> by ${changeSet.author} on ${commmitDate}, commit details below\n"
changeSet.affectedFiles.each { file ->
changeLogToReturn += " ${file.editType.name.capitalize()} - ${file.path}\n"
}
}
}
return changeLogToReturn;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment