{"id":15045319,"url":"https://github.com/jenkinsci/groovy-postbuild-plugin","last_synced_at":"2026-04-02T14:04:48.636Z","repository":{"id":547505,"uuid":"1163574","full_name":"jenkinsci/groovy-postbuild-plugin","owner":"jenkinsci","description":"Groovy postbuild plugin","archived":false,"fork":false,"pushed_at":"2026-03-26T19:16:39.000Z","size":409,"stargazers_count":31,"open_issues_count":20,"forks_count":51,"subscribers_count":92,"default_branch":"master","last_synced_at":"2026-03-27T08:14:32.283Z","etag":null,"topics":["adopt-this-plugin"],"latest_commit_sha":null,"homepage":"https://plugins.jenkins.io/groovy-postbuild/","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jenkinsci.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"community_bridge":"jenkins","custom":["https://www.jenkins.io/donate/#why-donate"]}},"created_at":"2010-12-13T05:37:10.000Z","updated_at":"2026-03-26T19:06:25.000Z","dependencies_parsed_at":"2026-01-19T15:02:05.663Z","dependency_job_id":null,"html_url":"https://github.com/jenkinsci/groovy-postbuild-plugin","commit_stats":{"total_commits":212,"total_committers":27,"mean_commits":7.851851851851852,"dds":0.7452830188679245,"last_synced_commit":"d5414f835c7ea9aa580ce28fe0cf0787c3786b9c"},"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"purl":"pkg:github/jenkinsci/groovy-postbuild-plugin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jenkinsci%2Fgroovy-postbuild-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jenkinsci%2Fgroovy-postbuild-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jenkinsci%2Fgroovy-postbuild-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jenkinsci%2Fgroovy-postbuild-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jenkinsci","download_url":"https://codeload.github.com/jenkinsci/groovy-postbuild-plugin/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jenkinsci%2Fgroovy-postbuild-plugin/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31307476,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T12:59:32.332Z","status":"ssl_error","status_checked_at":"2026-04-02T12:54:48.875Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["adopt-this-plugin"],"created_at":"2024-09-24T20:51:43.688Z","updated_at":"2026-04-02T14:04:48.616Z","avatar_url":"https://github.com/jenkinsci.png","language":"Java","funding_links":["https://funding.communitybridge.org/projects/jenkins","https://www.jenkins.io/donate/#why-donate"],"categories":[],"sub_categories":[],"readme":"# Groovy postbuild plugin\n\nThis plugin executes a groovy script in the Jenkins JVM as a post-build action (a publisher).\nTypically, the script checks some conditions and updates the build result, puts badges next to the build in the build history, and/or displays information on the build summary page.\n\nThe plugin honors the [markup formatter](https://www.jenkins.io/doc/book/security/markup-formatter/) defined in Jenkins.\nMarkup formatters that have been tested with the plugin include:\n\n* Plain text formatter, the Jenkins default\n* Safe HTML formatter, provided by the [OWASP markup formatter plugin](https://plugins.jenkins.io/antisamy-markup-formatter)\n* [Markdown](https://en.wikipedia.org/wiki/Markdown) formatter, provided by the [Markdown formatter plugin](https://plugins.jenkins.io/markdown-formatter/)\n\nReleases 228.vcdb_cf7265066 and before applied a subset of safe HTML formatting with no alternative formatter.\nUsers upgrading to newer releases may need to install the [OWASP markup formatter plugin](https://plugins.jenkins.io/antisamy-markup-formatter) and enable the safe HTML formatter in order to have the same interpretation of the text in their\ngroovy postbuild scripts. To enable it, go to Manage Jenkins -\u003e Security -\u003e Markup Formatter and select \"Safe HTML\".\n\n## Usage\n\nThe groovy script can use the variable `manager`, which provides various methods to decorate your builds.\nThose methods can be classified into *approved methods* and *non-approved methods*.\nYou can always use *approved methods*, but you can use *non-approved methods* only when \"Enable groovy postbuild security\" scripts are approved by administrators.\n\n### Approved methods\n\n-   `getEnvVariable(key)` - get a variable value.\n-   `getResult()` - get a build result string (like SUCCESS, FAILURE)\n\n#### Log methods\n\n-   `logContains(regexp)` - returns true if the build log file contains a line matching *regexp*.\n-   `getLogMatcher(regexp)` - returns a [java.util.regex.Matcher](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/regex/Matcher.html) for the first occurrence of *regexp* in the build log file.\n\n#### Short text methods\n\n-   `addShortText(text)` - puts a badge with a short text, using the default format.\n-   `addShortText(text, color, background, border, borderColor)` - puts a badge with a short text, using the specified format.\n    Supports html color names.\n\n#### Badge methods\n\n-   `addBadge(icon, text, link)` - like addBadge(icon, text), but the Badge icon then actually links to the given link\n-   `addInfoBadge(text)` - puts a badge with ![](docs/images/info.gif) info icon and the given text.\n-   `addWarningBadge(text)` - puts a badge with ![](docs/images/warning.gif) warning icon and the given text.\n-   `addErrorBadge(text)` - puts a badge with ![](docs/images/error.gif) error icon and the given text.\n-   `addHtmlBadge(html)` - puts a badge with html source. Unsafe html codes will be removed.\n-   `removeBadges()` - removes all badges from the current build. It is often used with `setBuildNumber`.\n-   `removeBadge(index)` - removes the badge with the given index. It is often used with `setBuildNumber`.\n-   `addBadge(icon, text)` - puts a badge with the given icon and text.\n    Provides the following icons:\n\n    \u003e ![](docs/images/completed.gif) - completed.gif\n    \u003e\n    \u003e ![](docs/images/db_in.gif) - db\\_in.gif\n    \u003e\n    \u003e ![](docs/images/db_out.gif) - db\\_out.gif\n    \u003e\n    \u003e ![](docs/images/delete.gif) - delete.gif\n    \u003e\n    \u003e ![](docs/images/error.gif) -  error.gif\n    \u003e\n    \u003e ![](docs/images/folder.gif) - folder.gif\n    \u003e\n    \u003e ![](docs/images/green.gif) - green.gif\n    \u003e\n    \u003e ![](docs/images/info.gif) - info.gif\n    \u003e\n    \u003e ![](docs/images/red.gif) - red.gif\n    \u003e\n    \u003e ![](docs/images/save.gif) - save.gif\n    \u003e\n    \u003e ![](docs/images/success.gif) - success.gif\n    \u003e\n    \u003e ![](docs/images/text.gif) - text.gif\n    \u003e\n    \u003e ![](docs/images/warning.gif) - warning.gif\n    \u003e\n    \u003e ![](docs/images/yellow.gif) - yellow.gif\n\n#### Build result methods\n\n-   `buildUnstable()` - sets the build result to *UNSTABLE*.\n-   `buildFailure()` - sets the build result to *FAILURE*.\n-   `buildSuccess()` - sets the build result to *SUCCESS*.\n\n#### Job type methods\n\n-   `buildIsA(klass)` - test the build is a specified class\n\n### Non-approved methods\n\nMethods returning non-primitive objects aren't approved.\nThe groovy postbuild plugin doesn't ensure that the methods of the returned object are safe.\n\n-   `build` - the current build - [javadoc](https://javadoc.jenkins.io/hudson/model/AbstractBuild.html)\n-   `jenkins` - the current controller instance - [javadoc](https://javadoc.jenkins.io/jenkins/model/Jenkins.html)\n-   `listener` - the build listener - [javadoc](https://javadoc.jenkins.io/hudson/model/BuildListener.html)\n\n#### Environment variables\n\n-   `envVars` - the build variables map. You can get a variable value with\n\n    ```groovy\n    manager.envVars['varname']\n    ```\n\n    Do not update the returned values.\n    This method is not recommended for any use.\n    Use `getEnvVariable(key)` instead.\n\n#### File content matching\n\n-   `contains(file, regexp)` - returns true if the given file contains a line matching *regexp*.\n    Not approved as it allows users access any files (for example, a file containing passwords).\n-   `getMatcher(file, regexp)` - returns a [java.util.regex.Matcher](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/regex/Matcher.html) for the first occurrence of *regexp* in the given file.\n\n#### Build number control\n\n-   `setBuildNumber(number)` - sets the build with the given number as current build.\n    The current build is the target of all methods that add or remove badges and summaries or change the build result.\n\n#### Summary modification\n\n-   `createSummary(icon)` - creates an entry in the build summary page and\n    returns a *summary* object corresponding to this entry.\n\n    The icon can be one of [IonIcons](https://ionic.io/ionicons) referenced by\n    `symbol-\u003cname\u003e plugin-ionicons-api`, or Jenkins core icon referenced by\n    `icon-\u003cname\u003e` or `symbol-\u003cname\u003e`. See examples [here](https://www.jenkins.io/doc/pipeline/steps/badge/#addbadge-add-badge).\n\n    You can append text to the *summary* object by\n    calling its *appendText* methods. Be careful appending\n    HTML-unescaped texts as they can be harmful.\n    -   `appendText(text, escapeHtml)`\n    -   `appendText(text, escapeHtml, bold, italic, color)`\n-   `removeSummaries()` - removes all summaries from the current build.\n-   `removeSummary(index)` - removes the summary with the given index.\n\n### Example usages\n\n#### Example 1\n\nThe script below puts a warning badge and mark the build as unstable if it detects that deprecated methods were used.\n\n```groovy\nif(manager.logContains(\".*uses or overrides a deprecated API.*\")) {\n    manager.addWarningBadge(\"Thou shalt not use deprecated methods.\")\n    manager.createSummary(\"warning.gif\").appendText(\"\u003ch1\u003eWarned!\u003c/h1\u003e\", false, false, false, \"red\")\n    manager.buildUnstable()\n}\n```\n\n![](docs/images/example1.png)\n\n#### Example 2\n\nSuppose we have a parameterized build, which uses the boolean parameter *storeToDB* in order to instruct the build to store some artifacts into the database.\nThe script below puts a badge next to the builds for which this parameter is set with short text.\n\n```groovy\n// Declarative Pipeline script block\nif (params.storeToDB) {\n    manager.addBadge(\"db_in.gif\", \"Stored in DB\")\n} else {\n    manager.addBadge(\"delete.gif\", \"Not stored in DB\")\n}\nmanager.addShortText(params.storeToDB ? \"In DB\" : \"Not in DB\")\n```\n\n![](docs/images/example2.png)\n\n#### Example 3\n\nSuppose we have a parameterized build, which uses the string parameter *version*.\nThe script below puts a short text indicating the value of this parameter next to successful and unstable builds.\n\n```groovy\ndef buildNumber = env.BUILD_ID as int\nif (buildNumber % 2) {\n    unstable(\"Setting build to unstable, version parameter is ${params.version}\")\n} else {\n    echo \"Not setting build to unstable, version parameter is ${params.version}\"\n}\n```\n\n![](docs/images/example3.png)\n\n#### Example 4\n\nThe script below determines how long it took to build the project and displays the corresponding value as a short text next to each build.\n\n```groovy\ndef matcher = manager.getLogMatcher(\".*Total time: (.*)\\$\")\nif(matcher?.matches()) {\n    manager.addShortText(matcher.group(1), \"grey\", \"white\", \"0px\", \"white\")\n}\n```\n\n![](docs/images/example4.png)\n\n#### Example 5\n\nFor badges, you can choose from the icons provided by this plugin.\nIf the name of a groovy-postbuild icon conflicts with the name of a Jenkins icon, provide the complete path to the icon.\n\n```groovy\nmanager.addBadge(\"yellow.gif\", \"icon from groovy-postbuild plugin\")\n```\n\n![](docs/images/example5.png)\n\n## Issues\n\nTo report a bug or request an enhancement to this plugin please create a ticket in JIRA (you need to login or to sign up for an account).\nPlease review and follow the instructions in [\"How to report an issue\"](https://www.jenkins.io/participate/report-issue/).\n\n-   [Open Issues](https://issues.jenkins.io/issues/?jql=resolution%20is%20EMPTY%20and%20component%3D15685)\n-   [Bug report or enhancement request](https://www.jenkins.io/participate/report-issue/redirect/#15685)\n\n## Changelog in [GitHub Releases](https://github.com/jenkinsci/groovy-postbuild-plugin/releases)\n\nRelease notes have been recorded in [GitHub](https://github.com/jenkinsci/groovy-postbuild-plugin/releases) since release 2.4.\nPrior release notes are in the historical [change log](https://github.com/jenkinsci/groovy-postbuild-plugin/blob/228.vcdb_cf7265066/CHANGELOG.md).\n\n## Migration from 1.X\n\nBeginning with version 2.0 (September 2014), Groovy Postbuild plugin introduces [Script Security Plugin](https://plugins.jenkins.io/script-security/).\nAdministrators can prevent users without proper privileges from running harmful scripts.\n\nFor details, see [Script Security Plugin](https://plugins.jenkins.io/script-security/).\nThis doesn't affect [Jenkins without security enabled](https://www.jenkins.io/doc/book/security/securing-jenkins/) and\nusers with administrative privilege (to be exact, with RUN\\_SCRIPTS\npermission).\n\nWhen you upgrade the Groovy Postbuild plugin from 1.X to 2.X, you and your Jenkins users\nmust update the configuration of Groovy Postbuild or they will fail with outputs like this:\n\n    ERROR: Failed to evaluate groovy script.\n    org.jenkinsci.plugins.scriptsecurity.scripts.UnapprovedUsageException: script not yet approved for use\n        at org.jenkinsci.plugins.scriptsecurity.scripts.ScriptApproval.using(ScriptApproval.java:398)\n        at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SecureGroovyScript.evaluate(SecureGroovyScript.java:165)\n        at org.jvnet.hudson.plugins.groovypostbuild.GroovyPostbuildRecorder.perform(GroovyPostbuildRecorder.java:343)\n        at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)\n        at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:785)\n        at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:757)\n        at hudson.model.Build$BuildExecution.post2(Build.java:183)\n        at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:706)\n        at hudson.model.Run.execute(Run.java:1690)\n        at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)\n        at hudson.model.ResourceController.execute(ResourceController.java:88)\n        at hudson.model.Executor.run(Executor.java:246)\n\n### Scripts using only approved methods of manager\n\nScripts using only [approved methods of manager](/#Approved-Methods) can run with the Groovy sandbox.\nThey can be validated by running with \"Use Groovy Sandbox\" checked in the job definition.\n\n![](docs/images/scriptsecurity-enablesandbox.png)\n\n### Scripts using non-approved methods\n\nScripts using [non-approved methods of manager](/#Non-approved-methods) or methods not of manager require administrator approval.\n\nAdministrators should check and approve those scripts in Manage Jenkins \\\u003e In-process Script Approval.\n\n![](docs/images/scriptsecurity-approvescript.png)\n\n### Scripts using external jar files\n\nIf you refer to external jar files from your scripts, those jar files must be approved by an administrator.\n\nAdministrators should check and approve those jar files in Manage \\\u003e In-process Script Approval.\n\n![](docs/images/scriptsecurity-approvejar.png)\n\n### Scripts using external class directories\n\n[Script Security Plugin](https://plugins.jenkins.io/script-security/) doesn't support class directories.\n\nIf you refer to external class directories from your scripts, you must archive them in jar files.\nIt can be performed by running a following command:\n\n    jar -cf mylib.jar -C /path/to/classes .\n\nYou can use /path/to/mylib.jar as an additonal classpath for scripts.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjenkinsci%2Fgroovy-postbuild-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjenkinsci%2Fgroovy-postbuild-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjenkinsci%2Fgroovy-postbuild-plugin/lists"}