Created
February 16, 2012 21:42
-
-
Save evilchili/1848087 to your computer and use it in GitHub Desktop.
invoke a downstream jenkins job with the current job parameters + additions
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
import hudson.model.* | |
// extract the version tag from the console log | |
def version_pattern = ".*\\[\\s*INFO\\s*\\]\\s+VERSION=(.*)\\s*\$" | |
def matcher = manager.getLogMatcher( version_pattern ) | |
if ( matcher?.matches() ) { | |
// add the version string to the job summary | |
def ver = matcher.group(1) | |
manager.addInfoBadge( "Version: $ver" ) | |
manager.createSummary("gear2.gif").appendText("<b>Version:</b> $ver", false ) | |
// prepare a list of parameters from the current build | |
def params = [] | |
for ( p in manager.build.getActions().find{ it instanceof ParametersAction } ) { | |
params.push( new StringParameterValue( p.name, p.value ) ) | |
} | |
// add the version string | |
params.push( new StringParameterValue( 'VERSION_STRING', ver ) ) | |
// schedule a build of the downstream job with current parameters | |
def job = manager.hudson.getJob('test-verification-Hello-Discworld-linux-x86-release') | |
job.scheduleBuild( 2, new Cause.UpstreamCause( manager.build ), new ParametersAction( params ) ) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment