This plugin executes a groovy script in the Jenkins 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.
From version 2.0, Groovy Postbuild plugin introduces Script Security Plugin.
When you upgrade the Groovy Postbuild plugin from 1.X to 2.X, you and your Jenkins users
Scripts using only whitelisted methods of manager can run with using Groovy sandbox.
Scripts using non-whitelisted methods of manager or methods not of manager requires
Administrators should check and approve those scripts in Manage Jenkins > In-process Script Approval.
If you refer external jar files from your scripts, you need to have those jar files approved by administartors.
Administrators should check and approve those jar files in Manage Jenkins > In-process Script Approval.
Script Security Plugin doesn't support class directories.
If you refer external class directories from your scripts, you should archive them into jar files.
You can use /path/to/mylib.jar as an additonal classpath for scripts.
The groovy script can use the variable manager, which provides various methods to decorate your builds.
Methods returning non-primitive objects aren't whitelisted as groovy-postbuild doesn't ensure every methods of those objects are safe.
It is also possible to delete badges and summaries by using the following links:
The script below puts a warning badge and mark the build as unstable if it detects that deprecated methods were used.
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.
Suppose we have a parameterized build, which uses the string parameter version. The script below puts a short text indicating the value of this parameter next to successful and unstable builds.
The script below determines how long it took to build the project and displays the corresponding value as a short text next to each build.
For badges, you can choose from the 16x16 icons provided by Jenkins or from the icons provided by this plugin. Some of the names of groovy-postbuild icons conflict with the names of Jenkins 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 Jenkins icon. You can also use icons provided by other plugins (e.g. Green Balls), by specifying the complete path to the icon.
The script below displays on the build summary page all classes that use Sun proprietary API.
The script below removes all badges and summaries from previous builds.
The script below marks the running build as deployed and the previous build as undeployed.
The script below changes the description of the first failed test.
Trivial, but hard to find the first time: Write a line to the job's Console Output:
Can use now additional classpath for groovy postbuild scripts to have them in a central location. Scriptler Plugin?
To report a bug or request an enhancement to this plugin please create a ticket in JIRA.
Skip to end of metadata Go to start of metadata