This plugin executes a groovy script in the Hudson JVM. Typically, the script checks some conditions and changes accordingly the build result, puts badges next to the build in the build history and/or displays information on the build summary page.

Usage

The groovy script can use the variable manager, which provides access to the following objects and methods:

addWarningBadge(text) - puts a badge with warning icon and the given text.

addErrorBadge(text) - puts a badge with error icon and the given text.

removeBadges() - removes all badges from the current build.

removeBadge(index) - removes the badge with the given index.

createSummary(icon) - creates an entry in the build summary page and returns a summary object corresponding to this entry. The icon must be one of the 48x48 icons offered by Hudson. You can append text to the summary object by calling its appendText methods:

appendText(text, escapeHtml)

appendText(text, escapeHtml, bold, italic, color)

removeSummaries() - removes all summaries from the current build.

removeSummary(index) - removes the summary with the given index.

buildUnstable() - sets the build result to UNSTABLE.

buildFailure() - sets the build result to FAILURE.

buildSuccess() - sets the build result to SUCCESS.

It is also possible to delete badges and summaries by using the following links:

Example 2

Suppose we have a parameterized build, which uses the boolean parameter storeToDB in order to instruct the build to store some artifacts into the database. The script below puts a badge next to the builds for which this parameter is set.

Example 5

For badges, you can choose from the 16x16 icons provided by Hudson or from the icons provided by this plugin. Some of the names of groovy-postbuild icons conflict with the names of Hudson icons (e.g. yellow.gif). For these icons, you have to provide the complete path (e.g. /images/16x16/yellow.gif), in case you want a badge with the Hudson icon. You can also use icons provided by other plugins (e.g. Green Balls), by specifying the complete path to the icon.

I think having a way to remove or edit badges and summaries would be awesome. Th...

I think having a way to remove or edit badges and summaries would be awesome. The only real way I can see to do this is to edit the config files directly. Even just providing some public methods that we can call through the groovy console (or the postbuild plugin itself) would be nice

This plugin is great.
I wondered how I could ever programmatically edit the des...

This plugin is great.

I wondered how I could ever programmatically edit the descriptions for failed testcases without writing a plugin. But with this plugin installed, it's basically just a few lines of code...something like this:

Is there a way to use the same groovy script within multiple jobs without having...

Is there a way to use the same groovy script within multiple jobs without having to cut-and-paste it each time?
I got a groovy postbuild script running, then I copied its contents verbatim to a file on Hudson master. Then, I tried this from Groovy Postbuild:
Eval.me(new File("/var/lib/hudson/userContent/postbuild-plugin.groovy").text);
But got this:
ERROR: Failed to evaluate groovy script.
groovy.lang.MissingPropertyException: No such property: manager for class: Script1
I tried a few things, but I couldn't get the embedded script to recognize my calls to the manager class.

HI.
I found yours post and it interest me.I like to set new runtime variable in...

HI.

I found yours post and it interest me.I like to set new runtime variable in one project and then us this variable in other (buildis parametrized, but not trigered by first one). How to do it by groovy script (or in diferent way)? I was trying to do that like you wrote, but I'm new user of Hudson and groovy scripts and I have some problems with that.

This might seem a basic question - but how do you query the manager.build object...

This might seem a basic question - but how do you query the manager.build object to determine the whether the build was successful or not? Is there a reference page to these various objects to see the methods available?

Hi,
Using this priority plugin, I'd like to change the priority of the job base...

Hi,

Using this priority plugin, I'd like to change the priority of the job based on whether or not the most recent build passed or failed. Any suggestions on how I could achieve this or if it is even possible?

I'm using the pmd and the report violoations post build action to trace it. Now ...

I'm using the pmd and the report violoations post build action to trace it. Now it would be nice to add a batch if the number of pmd violations has increased during this build. Is there a way to get these informations from the build model?

I'm using the pmd and the report violoations post build action to trace it. Now ...

I'm using the pmd and the report violoations post build action to trace it. Now it would be nice to add a batch if the number of pmd violations has increased during this build. Is there a way to get these informations from the build model?

The above code works only if GroovyPostbuild runs after the Violations plugin. One way to ensure this is to edit the config.xml of your project and to place the <org.jvnet.hudson.plugins.groovypostbuild.GroovyPostbuildRecorder> element after the <hudson.plugins.violations.ViolationsPublisher> element. Then, restart Hudson. The annoying thing is that the order of publishers is reset when saving the configuration, so you will have to repeat these operations each time you make a change to the project configuration.

To avoid these annoyances, you could build a custom version of GroovyPostbuild that will always run after the Violations plugin. In order to this, you have to retrieve the source code of GroovyPostbuild and adjust the annotation of GroovyPostbuildDescriptor: @Extension(ordinal=-1).