In my Jenkins pipeline, I can get change logs of the current build by this.

def changeLogSets = currentBuild.changeSets

Is there a way to get all change-logs since last successful build?

2 Answers 2


You may try something like this:

node('my_kubernetes_pod') {
    passedBuilds = []

    lastSuccessfulBuild(passedBuilds, currentBuild);

    def changeLog = getChangeLog(passedBuilds)
    echo "changeLog ${changeLog}"

def lastSuccessfulBuild(passedBuilds, build) {
    if ((build != null) && (build.result != 'SUCCESS')) {
        lastSuccessfulBuild(passedBuilds, build.getPreviousBuild())

def getChangeLog(passedBuilds) {
    def log = ""
    for (int x = 0; x < passedBuilds.size(); x++) {
        def currentBuild = passedBuilds[x];
        def changeLogSets = currentBuild.rawBuild.changeSets
        for (int i = 0; i < changeLogSets.size(); i++) {
            def entries = changeLogSets[i].items
            for (int j = 0; j < entries.length; j++) {
                def entry = entries[j]
                log += "* ${entry.msg} by ${entry.author} \n"
    return log;

Additionally, you may try out "Changes Since Last Success Plugin": https://wiki.jenkins.io/display/JENKINS/Changes+Since+Last+Success+Plugin

But it will not work together with pipeline, this is a separate approach.

  • It seems this solution gives the change logs of last succesaful builds. What I actually was looking for was chnage logs (of last unsuccessful builds) since last successful build. But your answr is definitely helpful. Build.getpreviousebuuld() and recursion was what i had missed. Thank you very much for the answer.
    – Bee
    Oct 14, 2017 at 5:58
  • 1
    Always welcome ;-)
    – user54
    Oct 14, 2017 at 6:33
  • I suspect that the recursive solution might run into problems running out of stack if you had it going through a lot of builds. Wouldn't be too hard to switch to an iterative process though.
    – drewish
    Oct 28, 2017 at 18:46

As I found may be this will helps you. With this you can fetch latest successful build change log file of any project build with Jenkins.

$DirectoryA = "D:\Jenkins\jobs\projectName\builds"  ####Jenkind directory
$firstfolder = Get-ChildItem -Path $DirectoryA | Where-Object {$_.PSIsContainer} | Sort-Object LastWriteTime -Descending | Select-Object -First 1
$DirectoryB = $DirectoryA + "\" + $firstfolder

$sVnLoGfIle = $DirectoryB + "\" + "changelog.xml" 

write-host $sVnLoGfIle
  • In Jenkins\jobs\projectName\builds\75\ I don't see the last changelog file but on the Jenkins dashboard, I see the last-changes option and changes so where to find exactly this last-change file? Apr 30, 2021 at 2:54
  • Hey @Ashish, You can find jenkins home directory path "http//:ip:8080/jenkins/configure". In that directory there must be a job`s folder. Changes reflect only for jobs not for any pipeline. 75 is just a build id into that folder you can see "changelog.xml" file
    – Ashu
    Aug 30, 2021 at 12:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.