Executes a groovy script in the Hudson JVM. Typically, the script checks some conditions and changes accordingly the build result and/or puts badges next to the build in the build history.
The groovy script can use the variable manager, which provides access to the following objects and methods:
- hudson - the current Hudson instance.
- build - the current build.
- listener - the build listener.
- contains(file, regexp) - returns true if the given file contains a line matching regexp.
- logContains(regexp) - returns true if the build log file contains a line matching regexp.
- getMatcher(file, regexp) - returns a java.util.regex.Matcher for the first occurrence of regexp in the given file.
- getLogMatcher(regexp) - returns a java.util.regex.Matcher for the first occurrence of regexp in the build log file.
- addShortText(text) - puts a badge with a short text, using the default format.
- addShortText(text, color, background, border, borderColor) - puts a badge with a short text, using the specified format.
- addBadge(icon, text) - puts a badge with the given icon and text.
- addInfoBadge(text) - puts a badge with
info icon and the given text.
- addWarningBadge(text) - puts a badge with
warning icon and the given text.
- addErrorBadge(text) - puts a badge with
error icon and the given text.
- buildUnstable() - sets the build result to UNSTABLE.
- buildFailure() - sets the build result to FAILURE.
- buildSuccess() - sets the build result to SUCCESS.
Example: if(manager.logContains(".*uses or overrides a deprecated API.*")) {
manager.addWarningBadge("Thou shalt not use deprecated methods.")
manager.buildUnstable()
}