Let us assume that your job prints something like "Front-End Version: 1.2509". Here is how you print the version number in the jenkins job history:
- Install "Groovy Postbuild" plugin.
- Add a post build action type "Groovy postbuild"
- Insert the below in "Groovy Script" and save
def m = manager.getLogMatcher("^.*Front-End Version: (.*)\$") // to debug using job logs // manager.listener.logger.println("found version:" + m.group(1)) if(m != null && m.matches()) { version = m.group(1) manager.addShortText(version) }
- Run the job and you will get the version number next to the build.
4 comments:
Doesn't the Description Setter plugin accomplish the same thing? https://wiki.jenkins-ci.org/display/JENKINS/Description+Setter+Plugin
@Ross Thanks for pointing that out. Yes either Description or Name Setter Plugins could achieve something similar. Of course the Groovy Post Build Plugin allows for parsing multi lines and display the information as Name or Description but definitely the Description or Name Setter Plugins look like simpler (and to me better) alternatives for the subject of this post. Thanks for sharing!
Typically you would use the description name plugin when you already know the version of the app you are using. To me setting the version in the build description from log output is caused from a broken pipeline where the version of the application is not at the starting point of the pipeline nor passed to all dependent jobs.
@Deryl we live in a wonderful but imperfect world. At least the plugins mentioned here help you deal with an imperfection in a cost effective way.
Post a Comment