About Alex Soto

Jenkins Description Setter Plugin for Improving Continuous Delivery Visibility

In Continuous Delivery each build is potentially shippable. This fact implies among a lot of other things, to assign a none snapshot version to your components as fast as possible so you can refer them through all the process. I suggest creating a release branch, assign the version to the project and then start the typical pipeline (compile, tests, code quality …) steps to release branch.
If you are using Jenkins, your build job screen will look something like:

Note that we have released the project many times, but there is no quick way to know exactly which version has been constructed in build number 40. To avoid this problem and having a quick overview of which version has been executed in each build job instance, we can use Jenkins description setter plugin. This plugin sets the description for each build, based upon a regular expression of the build log file. So your build job screen will look something like:

Much better, now we know exactly the result of a build job and which product version has been generated. So first step is installing the plugin by simply going to: Jenkins -> Manage Jenkins -> Manage Plugins -> Available. After installation you can open Build Job configuration screen and add a post-build action called ‘ Set build description‘. Then add a regular expression for extracting the version number. In this case the regular expression is: \[INFO\] from version 0\.0\.1-SNAPSHOT to (.*)

Take a look at next fragment of build log file:


          [INFO] Scanning for projects...


          [INFO] ------------------------------------------------------------------------

          [INFO] Building hello 0.0.1-SNAPSHOT

          [INFO] ------------------------------------------------------------------------


          [INFO] --- versions-maven-plugin:2.0:set (default-cli) @ hello ---

          [INFO] Searching for local aggregator root...

          [INFO] Local aggregation root: /jobs/helloworld-inital-build/workspace

          [INFO] Processing com.lordofthejars.helloworld:hello

          [INFO]     Updating project com.lordofthejars.helloworld:hello

          [INFO]         from version 0.0.1-SNAPSHOT to 1.0.43

          Props: {project.version=1.0.43, project.artifactId=hello, project.groupId=com.lordofthejars.helloworld}

At line 12 we are logging the final version of our product for current pipeline execution, so we create a regular expression which parses that line and the part between brackets are used as decorator. Depending on log traces the regular expression will differ from this one. In this case, we are always using the same SNAPSHOT version in development and only when product is going to be released (this could be 3 times per day or every night) the final version is generated and set. Hope this plugin helps you to make your builds more clear.

Reference: Jenkins Description Setter Plugin for Improving Continuous Delivery Visibility from our JCG partner Alex Soto at the One Jar To Rule Them All blog.

Related Whitepaper:

Software Architecture

This guide will introduce you to the world of Software Architecture!

This 162 page guide will cover topics within the field of software architecture including: software architecture as a solution balancing the concerns of different stakeholders, quality assurance, methods to describe and evaluate architectures, the influence of architecture on reuse, and the life cycle of a system and its architecture. This guide concludes with a comparison between the professions of software architect and software engineer.

Get it Now!  

One Response to "Jenkins Description Setter Plugin for Improving Continuous Delivery Visibility"

  1. Anton Leskovets says:

    Is there any way to use extracted version as a variable?

Leave a Reply

9 + four =

Java Code Geeks and all content copyright © 2010-2014, Exelixis Media Ltd | Terms of Use | Privacy Policy
All trademarks and registered trademarks appearing on Java Code Geeks are the property of their respective owners.
Java is a trademark or registered trademark of Oracle Corporation in the United States and other countries.
Java Code Geeks is not connected to Oracle Corporation and is not sponsored by Oracle Corporation.
Do you want to know how to develop your skillset and become a ...
Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you two of our best selling eBooks for FREE!

Get ready to Rock!
You can download the complementary eBooks using the links below: