Last active
June 27, 2019 17:16
-
-
Save dnozay/fc528b43cf27755017cc to your computer and use it in GitHub Desktop.
Jenkins - add badge & summary to promoted build
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// When using the Promoted Build plugin, you may want to perform some operations | |
// then you may also want to add badges or a summary to the target build as | |
// opposed to the promotion build. This script assumes that you have a manual | |
// promotion process with a parameter called RELEASE_VERSION (hence requiring | |
// user input); the content that follows would be what you put as a Groovy | |
// Postbuild action on the promotion process. | |
import org.jvnet.hudson.plugins.groovypostbuild.*; | |
def add_release_version(promotion) { | |
target = promotion.target; | |
// access the promotion build environment and the RELEASE_VERSION parameter. | |
release_version = promotion.environment.get('RELEASE_VERSION'); | |
// create the summary with the gold star icon and attach to target. | |
GroovyPostbuildSummaryAction action = new GroovyPostbuildSummaryAction("star-gold.png"); | |
target.getActions().add(action); | |
// customize text for the summary. | |
action.appendText("RELEASE VERSION = " + release_version, false); | |
// also add a short text that will appear in the build history | |
target.getActions().add(GroovyPostbuildAction.createShortText(release_version)); | |
// save the build! | |
target.save() | |
} | |
// get the build that this promotion is for. | |
promotion = manager.build; | |
add_release_version(promotion); |
@lvthillo - you may need to install the relevant plugin for the classes to be available.
added snippet to collection > https://gist.github.com/dnozay/e7afcf7a7dd8f73a4e05
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
import org.jvnet.hudson.plugins.groovypostbuild.*;
fails for me?