Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get list of changed files since last build in Jenkins/Hudson

Tags:

jenkins

hudson

I have set up Jenkins, but I would like to find out what files were added/changed between the current build and the previous build. I'd like to run some long running tests depending on whether or not certain parts of the source tree were changed.

Having scoured the Internet I can find no mention of this ability within Hudson/Jenkins though suggestions were made to use SVN post-commit hooks. Maybe it's so simple that everyone (except me) knows how to do it!

Is this possible?

like image 385
Allan Avatar asked Jun 07 '11 03:06

Allan


People also ask

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.

What is used to track the changes between builds in Jenkins?

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.


1 Answers

I have done it the following way. I am not sure if that is the right way, but it seems to be working. You need to get the Jenkins Groovy plugin installed and do the following script.

import hudson.model.*; import hudson.util.*; import hudson.scm.*; import hudson.plugins.accurev.*  def thr = Thread.currentThread(); def build = thr?.executable;  def changeSet= build.getChangeSet();  changeSet.getItems(); 

ChangeSet.getItems() gives you the changes. Since I use accurev, I did List<AccurevTransaction> accurevTransList = changeSet.getItems();.

Here, the modified list contains duplicate files/names if it has been committed more than once during the current build window.

like image 184
Srini Avatar answered Sep 17 '22 11:09

Srini