Marking upstream jobs as failed in jenkins without finger printing

Marking upstream jobs as failed in jenkins without finger printing

14 February 2014

This script not longer works and fails with: cannot change build result while in COMPLETED

Please DISREGARD this article.


I use the Build Pipeline Plugin and the Groovy Postbuild Plugin to allow me to set all builds upstream to failed in a downstream job failed.

I have the following pipeline:


When the (Down) job fails I want to mark upstream jobs (Top) and (Root) as failed.

I did this using groovy in the post build and best of all; NO fingerprinting required!

Anyway, the script is below. Get copying and modifying!

* Will mark all upstream builds as failed if the current job is
* Fingerprinting not required.
* Author:Colin Williamson

import hudson.model.*

void log(msg) {

def failRecursivelyUsingCauses(cause) {
     if (cause.class.toString().contains("UpstreamCause")) {
        def projectName = cause.getUpstreamProject()
        def number = cause.getUpstreamRun().number
        upstreamJob = hudson.model.Hudson.instance.getItem(projectName)
        if(upstreamJob) {
             upbuild = upstreamJob.getBuildByNumber(number)
             if(upbuild) {
                 log("Setting to failed for " + projectName + " - " + number)
                 // fail other builds
                 for (upCause in cause.upstreamCauses) {
        } else {
            log("No Upstream job found for " + projectName);

if( {
    log("Must fail upstream builds");
    for (cause in {
else {
    log("Success - not changing");
CI Jenkins-CI