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.
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.
createSummary(icon)
- creates an entry in the build summary page and returns a summary object corresponding to this entry. You can append text to the summary object by calling its appendText methods:
- appendText(text, escapeHtml)
- appendText(text, escapeHtml, bold, italic, color)
-
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.createSummary("warning.gif").appendText("<h1>You have been warned!</h1>", false, false, false, "red")
manager.buildUnstable()
}
See Hudson Wiki for more information.