• Icon: New Feature New Feature
    • Resolution: Fixed
    • Icon: Major Major
    • pipeline
    • None

      Workflow scripts would often like to behave differently depending on the SCM changelog(s) for the current build (or perhaps a downstream build). You can use currentBuild.rawBuild.changeSets but this is not accessible from the sandbox.

          [JENKINS-30412] Access to build's own changelog from script

          Jesse Glick created issue -
          Jesse Glick made changes -
          Link New: This issue is related to JENKINS-26100 [ JENKINS-26100 ]

          Jesse Glick added a comment -

          Workaround in the case of Git for a non-sandboxed build:

          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]
                  echo "${entry.commitId} by ${entry.author} on ${new Date(entry.timestamp)}: ${entry.msg}"
                  def files = new ArrayList(entry.affectedFiles)
                  for (int k = 0; k < files.size(); k++) {
                      def file = files[k]
                      echo "  ${file.editType.name} ${file.path}"
                  }
              }
          }
          

          Jesse Glick added a comment - Workaround in the case of Git for a non-sandboxed build: 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] echo "${entry.commitId} by ${entry.author} on ${ new Date(entry.timestamp)}: ${entry.msg}" def files = new ArrayList(entry.affectedFiles) for ( int k = 0; k < files.size(); k++) { def file = files[k] echo " ${file.editType.name} ${file.path}" } } }

          Jesse Glick added a comment -

          Also requested: to get the aggregate changelog for all builds since the last successful (or stable).

          Jesse Glick added a comment - Also requested: to get the aggregate changelog for all builds since the last successful (or stable).
          Jesse Glick made changes -
          Epic Link New: JENKINS-35391 [ 171184 ]
          Jesse Glick made changes -
          Link New: This issue is related to JENKINS-27092 [ JENKINS-27092 ]
          Jesse Glick made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]
          Jesse Glick made changes -
          Link New: This issue depends on JENKINS-24141 [ JENKINS-24141 ]

          Jesse Glick added a comment -

          Aggregate changelog can be computed in terms of the above, so I will leave this to some helper library.

          Jesse Glick added a comment - Aggregate changelog can be computed in terms of the above, so I will leave this to some helper library.
          Jesse Glick made changes -
          Remote Link New: This issue links to "workflow-support PR 5 (Web Link)" [ 14548 ]

            jglick Jesse Glick
            jglick Jesse Glick
            Votes:
            5 Vote for this issue
            Watchers:
            15 Start watching this issue

              Created:
              Updated:
              Resolved: