Avoid Unnecessary Builds with Jenkins, Maven and SVN

Sooner or later your CI server will became very busy, and your frustration will grow because of increasing wait time for each build. One thing you can do to improve the situation is to avoid running jobs when there is no need to do so.

I use Jenkins + Maven + SVN in this example, but you can use this "tricks" also when using different technologies - Gradle, Git etc.

Ignore Files

Ok, so the thing is that build should be run only if some important changes happen. Should your whole pipeline start only because you fixed a typo in README.txt file? Obviously not.
We can fix it by telling Jenkins to ignore commits to certain files using the Advanced sections of SVN configuration of your job. Go there, and add to "Excluded Regions" paths to files which should NOT trigger the build.

For example. If your SVN checkout URL is https://my.subversion.server/svn/myproject/trunk and the README.txt file resides in the main directory, then you should add the following path to "Excluded Regions": .*README.*

Now try to commit the README.txt and see if it triggers this job.

BTW. In my humble opinion this "Exclude Regions" is borked. I have never ever succeeded to exclude stuff by path even though I tried various combinations (e.g. like trunk/README.txt or /trunk/.*.txt and many more). The only thing that worked for me are regexes like .*README.*.

Ignore Users

Similarly, when you create a release of your library (using Maven-Release-Plugin), then Maven will commit new pom.xml files. This will of course start your build. This time you can't add pom.xml files to ignore, but you can ignore commits done by Jenkins. I assume your CI server has a separate SVN user, so simply add it to "Excluded Users"

That's all for today!

P.S. I do not claim that this will solve all your CI performance problems. But eliminating useless things is always nice, so why don't you give it a try?

 
 
 
This used to be my blog. I moved to http://tomek.kaczanowscy.pl long time ago.

 
 
 

Please comment using