I'm trying to expand the post How to get the changes since the last successful build in jenkins pipeline?. How can I get the files that changed between the current build and the last successful build in the change set instead of the log? I don't want the actual changes in each file, but only a list of files that changed. I want the equivalent of doing a
$ git diff commit#1 commit#2 --name-only
Note I modified this function to at least get the change sets between the current build and the last successful build. In my case, I set the currentBuild
state to SUCCESS
so it's counted as a passedBuild
, hence the check for passedBuilds.size() < 2
.
////////////////////////////////////////////////////////////////////
// Code to get change sets between the current and last successful
// build
////////////////////////////////////////////////////////////////////
def lastSuccessfulBuild(passedBuilds, build) {
if (build != null) {
if (build.result != 'SUCCESS' || passedBuilds.size() < 2) {
passedBuilds.add(build)
lastSuccessfulBuild(passedBuilds, build.getPreviousBuild())
}
}
}
Thanks in advance.