title: Jenkinsfile, get all modified files in the PR
body: <p>I want to have a list of modified files in the PR, I tried a few solutions but I can only have access to the modified files in the last commits pushed to remote.</p>
  
  <p><strong>Example:</strong></p>
  
  <ul>
  <li>Create a PR with 3 commits, a new jenkins job starts;</li>
  <li>The list of modified files includes all files from the 3 commits; </li>
  <li>The build fails, push a new commit with the fix into the PR, a new jenkins jobs starts; </li>
  <li>The list of modified files only includes the files of the new commit;</li>
  </ul>
  
  <p>So, in this example I want to have the list of files from all the new commits in the PR.</p>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>  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]
              def files = new ArrayList(entry.affectedFiles)
              for (int k = 0; k &lt; files.size(); k++) {
                  def file = files[k]
                  print file.path 
              }
          }
      }
  </code></pre>