Last active
October 26, 2018 13:41
-
-
Save yogeshlonkar/dfc61ee1ea1f42c746940666b350065b to your computer and use it in GitHub Desktop.
Jenkins currentBuild getChangeLog as a string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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