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

5

8

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.

Regalia answered 26/5, 2011 at 15:20 Comment(1)
This approach is very useful (see the top rated solution): #5487604Goodin
R
6

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.

Regalia answered 14/6, 2011 at 17:25 Comment(0)
E
5

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.

Electoral answered 31/5, 2011 at 5:24 Comment(1)
Hello, thanks for your answer, but, could you explain me a little bit more what you mean?, i don't see how can i use that plugin to make the parent fails if the downstream jobs fail. Thanks!Regalia
D
1

We had a similar sort of issue and haven't found a perfect solution. A partial solution is to use the Promoted Builds Plugin. Configure it for your upstream project to include some visual indicator when the downstream job finishes. It doesn't change the overall job status, but it does notify us when the downstream job fails.

Davey answered 27/5, 2011 at 15:44 Comment(0)
P
1

Perhaps this plugin does what you are looking for?

Jenkins Prerequisite build step Plugin

Pustule answered 8/7, 2011 at 20:12 Comment(0)
R
0

the work around for my project is to create a new job, which is the down stream of the down streams. We set a post build step "Trigger parameterized build on other projects " in all three of the original downstream jobs. The parameter that parse into the new job depends on the three jobs' status and the parameter will causes the new job react accordingly.

1. Create new job which contains one simple class and one simple test. Both parameters dependens, i.e. class fail if parameter "status" = fail, class pass but test fail if parameter "status"=unstable, etc.

2. Set Trigger parameterized build on other projects for the three original downstream jobs with relevant configurations.

3. Set notification of the new job accordingly.

Rationalism answered 1/6, 2011 at 11:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.