Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 392
victorgp Avatar asked May 26 '11 15:05

victorgp


People also ask

What is the difference between upstream and downstream in Jenkins?

An upstream job is a configured project that triggers a project as part of its execution. A downstream job is a configured project that is triggered as part of a execution of pipeline.

How do I change the status color in Jenkins?

Generally, the green color is universal indicator of success status. If you want, you can change job status to green for success status. Select it and then install. After this, once the job build status is success, ball color would be green.

How does Jenkins pipeline trigger downstream job?

Select a job that triggers a remote one and then go to Job Configuration > Build section > Add Build Step > Trigger builds on remote/local projects option. This configuration allows you to trigger another exciting job on a different CM (remote). The downstream job name part will autocomplete.


2 Answers

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.

like image 171
victorgp Avatar answered Sep 28 '22 08:09

victorgp


Another option that might work for you is to use the parametrised build plugin. It allows you to have your 4 "downstream" builds as build steps. This means that your "parent" build can fail if any of the child builds do.

We do this when we want to hide complexity for the build-pipeline plugin view.

like image 27
Geoff Bullen Avatar answered Sep 28 '22 07:09

Geoff Bullen