Which Jenkins Command to Get the List of Changed Files
You can use the changeSets property of the currentBuild global variable to get information relating to the detected changes of the current build.
e.g.
// returns a list of changed files@NonCPSString getChangedFilesList() { changedFiles = [] for (changeLogSet in currentBuild.changeSets) { for (entry in changeLogSet.getItems()) { // for each commit in the detected changes for (file in entry.getAffectedFiles()) { changedFiles.add(file.getPath()) // add changed file to list } } } return changedFiles}
Possibly one of the two possible commands listed in "How to list all the files in a commit?":
git diff-tree --no-commit-id --name-only -r <commit-ish>
Note that the Jenkins Git plugin does expose that commit as an environment variable: GIT_COMMIT