Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins set a badge as a pre-build step

I'm not sure I have terminology quite correct here, so I will try to explain as best as possible. I use Jenkins to run our Java automation. There are lots of long-running (2-10 hours) jobs executing constantly against different versions of the product under test. I need a way to look quickly at the Build History box of a job, and see which job is testing which product version.

I've used the Groovy Postbuild plugin successfully to add a badge (I think that is what it is) to the right of the build in the Build History Box. The actual groovy command is:

manager.addShortText(version, "grey", "white", "0px", "white")

The problem with this, is that it does not run until the build is complete. I need to do something like this before the build starts. (I will have access to the version pre-build, as it is passed in as a parameter)

like image 803
Matt Herbert Avatar asked Mar 21 '14 15:03

Matt Herbert


1 Answers

You could use the Groovy Plugin (not groovy post-build) and execute a script as first action of your build (you need to use a system script in order to access Jenkins' classes.

Note however, that the mananger in groovy post build plugin is a shortcut, so you would need something like:

build.getActions().add(GroovyPostbuildAction.createShortText(text));

Update:

Since the above construct does not quite work, try:

 def action = new org.jvnet.hudson.plugins.groovypostbuild.GroovyPostbuildAction(null, text);
 action.color = "grey";
 build.getActions().add(action);

Alternativly, you could just set the description:

build.description = text
like image 193
blackbuild Avatar answered Oct 22 '22 08:10

blackbuild