Home > database >  Jenkins job to catch a particular error message from downstream job and retrigger it
Jenkins job to catch a particular error message from downstream job and retrigger it

Time:09-10

Hi i am trying to retrigger a downstream job if the job fails during first build with a error "invalid JWT token" , i want this job to retrigger again with changed parameters.

i am able to retrigger it with different parameters as of now, but what i want to achieve here is i want the job to retrigger only if i get the error as " invalid Jwt token" only.

can someone help me with this , i am trying to make us of try-catch block

this is the pipeline job as of now

enter image description here

CodePudding user response:

I assume you decide on the error by looking at the log of the second Job. If that's the case have a look at the following. Here I'm using propagate: false

pipeline {
    agent any
    stages {
        stage('Job') {
            steps {
                script {
                    def jobBuild = build(job: 'SecondJob', wait: true,  propagate: false)
                    def result = jobBuild.getResult()
                    if(result == "FAILURE"){
                        def log = jobBuild.getRawBuild().getLog()
                        if(log.contains("invalid JWT token")){
                            echo "Rerunning the JOB!!!!"
                        }
                    } 
                }
            }
        }
    }
}

CodePudding user response:

Job for code...how need error in job,...not answear and questions too code for what you need...simple no code, no job it's not eroding but just humanity code minority complaint and complicated....trancemirroring good future technology humidity naturally controls your//human its true

  • Related