I have Jenkins configured to build on pull requests (PR). Our repository is a multi project repository and I have created a script to detect the changes that were made to source code and only run tests that are relevant to the projects that had changes in them (according to the changed file's path):
def getChangedProjects() {
Set projects = []
def changeLogSets = currentBuild.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]
def files = new ArrayList(entry.affectedFiles)
for (int k = 0; k < files.size(); k++) {
def file = files[k]
// get the project folder name and
// add it to changed projects set
projects.add(file.path.tokenize('/')[1])
}
}
}
return projects.findAll {it != null}
}
The Groovy function works as expected and detects the folder that has changed.
Problem is that most of the times Jenkins will not show any changes in Jenkins:
But the PR did contain changes to files and I can see these changes in Github of course.
Anyone know why Jenkins is not showing the changes ?
You may create a change log by including a Git Changelog step in the Jenkins pipeline script.
This plugin provides a context object that contains all the information needed to create a changelog. It can also provide a string that is a rendered changelog, ready to be published.
Here is a screenshot of a sample Git changelog produced by this plugin:
More information about this plugin may be found in its wiki.
Hope, it helps.
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