Home > front end >  Jenkins downstream error not propagated to upstream
Jenkins downstream error not propagated to upstream

Time:12-06

I have a pipeline to build which will trigger another pipeline for running the (long) tests. My idea is to have the downstream test job run without waiting (to allow frequent build jobs). However, when I add wait: false to the build job command a failure will not change the status of the build job:

JenkinsfileBuild

node {

    def app

    stage('Clone repository') {
    }

    stage('Merge main') {
    }

    stage('Build image') {
    }

    stage('Upload image') {

        sh "echo would push image here"
    }

}

stage('Test Image') {
    build job: "../${env.JOB_NAME.split("/")[0]}Test/${env.BRANCH_NAME}", wait: false 
}

JenkinsfileTest

node {

    stage('Run Test') {
        sh "exit -1";
    }

}

I was expecting that the failing test job would mark the build job as failed as it does, when wait: true is set.

What am I missing?

CodePudding user response:

Add propagate: true option to the build step. And you need to wait for the Job in order to get the result.

build job: "../${env.JOB_NAME.split("/")[0]}Test/${env.BRANCH_NAME}", wait: true, propagate: true
  • Related