Answers: <p>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. </p>
  
  <pre><code>$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
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2021-04-30T02:54:52.740Z
Answers: 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?
Answers: Ashish Karpe
Answers: CC BY-SA 4.0
Answers: 2021-08-30T12:46:11.743Z
Answers: 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
Answers: Ashu
Answers: CC BY-SA 4.0
Answers: 2018-07-19T05:34:05.190Z
Answers: 2018-07-19T05:34:05.190Z
Answers: Ashu
Answers: <p>You may try something like this: </p>
  
  <pre><code>node('my_kubernetes_pod') {
      passedBuilds = []
  
      lastSuccessfulBuild(passedBuilds, currentBuild);
  
      def changeLog = getChangeLog(passedBuilds)
      echo "changeLog ${changeLog}"
  }
  
  def lastSuccessfulBuild(passedBuilds, build) {
      if ((build != null) &amp;&amp; (build.result != 'SUCCESS')) {
          passedBuilds.add(build)
          lastSuccessfulBuild(passedBuilds, build.getPreviousBuild())
      }
  }
  
  @NonCPS
  def getChangeLog(passedBuilds) {
      def log = ""
      for (int x = 0; x &lt; passedBuilds.size(); x++) {
          def currentBuild = passedBuilds[x];
          def changeLogSets = currentBuild.rawBuild.changeSets
          for (int i = 0; i &lt; changeLogSets.size(); i++) {
              def entries = changeLogSets[i].items
              for (int j = 0; j &lt; entries.length; j++) {
                  def entry = entries[j]
                  log += "* ${entry.msg} by ${entry.author} \n"
              }
          }
      }
      return log;
  }
  </code></pre>
  
  <p>Additionally, you may try out "Changes Since Last Success Plugin":
  <a href="https://wiki.jenkins.io/display/JENKINS/Changes+Since+Last+Success+Plugin" rel="noreferrer">https://wiki.jenkins.io/display/JENKINS/Changes+Since+Last+Success+Plugin</a></p>
  
  <p>But it will not work together with pipeline, this is a separate approach.</p>
  
Answers: CC BY-SA 3.0
Answers: 2017-10-14T05:58:42.157Z
Answers: 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.
Answers: Bee
Answers: CC BY-SA 3.0
Answers: 2017-10-14T06:33:30.660Z
Answers: Always welcome ;-)
Answers: user54
Answers: CC BY-SA 3.0
Answers: 2017-10-28T18:46:21.970Z
Answers: 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.
Answers: drewish
Answers: CC BY-SA 3.0
Answers: 2017-10-13T21:48:17.670Z
Answers: 2017-10-13T21:48:17.670Z
Answers: user54
Body: <p>In my Jenkins pipeline, I can get change logs of the current build by this.</p>
  
  <pre><code>def changeLogSets = currentBuild.changeSets
  </code></pre>
  
  <p>Is there a way to get all change-logs since last successful build? </p>
  
Tags: <jenkins><jenkins-pipeline>
Title: Get all change logs of since last successful build in Jenkins Pipeline
UserDisplayName: Bee
ThreadText: # Get all change logs of since last successful build in Jenkins Pipeline
  
  (Asked by: username_0 on 2017-10-13)
  
  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?
  
  **Tags:** jenkins, jenkins-pipeline
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_3 on 2017-10-13. Score: 12 | Accepted answer
  
  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')) {
          passedBuilds.add(build)
          lastSuccessfulBuild(passedBuilds, build.getPreviousBuild())
      }
  }
  
  @NonCPS
  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.
  
  > **Comments:**
  > **username_0**: 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.  
  > **username_3**: Always welcome ;-)  
  > **username_4**: 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.  
  
  ---
  
  ### Answer by username_1 on 2018-07-19. Score: 2
  
  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
  
  ```
  
  > **Comments:**
  > **username_2**: 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?  
  > **username_1**: Hey @username_2, 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  
  
  ---
  
  