title: How to get list of changed files in Jenkinsfile for a pull request?
body: <p>Is it possible to get a list of changed files in the Jenkinsfile during a pull request build? I am currently doing this...</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>
  <p>but if I am building a new branch for the very first time this method does not return any changes because there is no previous build to compare to. Has anyone found a solution to this?</p>
  <p>Thanks</p>