Jenkins/Hudson upstream job does not get the status “ball” color of the downstream jobs

continuous integrationhudsonhudson-pluginsJenkins

I have a job upstream that executes 4 downstream jobs.

If the upstream job finish successfully the downstream jobs start their execution.

The upstream job, since it finish successfully, gets a blue ball (build result=stable), but even tough the downstream jobs fail (red ball) or are unstable (yellow ball), the upstream job maintain its blue color.

Is there anyway to get the result of the upstream job dependent on the downstream jobs?, i mean, if three downstream jobs get a stable build but one of them get an unstable build, the upstream build result should be unstable.

Best Answer

I found the solution. There is a plugin called Groovy Postbuild pluging that let you execute a Groovy script in the post build phase. Addind a simple code to the downstream jobs you can modify the upstream overall status.

This is the code you need to add:

upstreamBuilds = manager.build.getUpstreamBuilds();

upstreamJob = upstreamBuilds.keySet().iterator().next();

lastUpstreamBuild = upstreamJob.getLastBuild();

if(lastUpstreamBuild.getResult().isBetterThan(manager.build.result)) {
    lastUpstreamBuild.setResult(manager.build.result);
}

You can find more info in the entry of my blog here.

Related Topic