victorgp
victorgp

Reputation: 882

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.

Upvotes: 8

Views: 7036

Answers (5)

jaustin
jaustin

Reputation: 191

Perhaps this plugin does what you are looking for?

Jenkins Prerequisite build step Plugin

Upvotes: 1

user454043
user454043

Reputation:

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.

Upvotes: 0

victorgp
victorgp

Reputation: 882

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.

Upvotes: 6

Geoff Bullen
Geoff Bullen

Reputation: 264

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.

Upvotes: 5

Jason Swager
Jason Swager

Reputation: 6501

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.

Upvotes: 1

Related Questions