In a Jenkins build I see a list of changed files:
So which command Jenkins uses to get this list (I am using git for repository version control).
The simplest way to know what has changed on your Jenkins builds! Last Changes is a Jenkin plugin that shows rich VCS diffs between builds. Only Git and Svn based projects are supported.
currentBuild is a global variable that may be used to refer to the currently running build.
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
@NonCPS
String 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
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With