jenkins pipeline catch build_job info for a failed parallel build

Does anyone know how to catch the failed job’s number in a parallel pipeline execution while still have failFast feature working for short-circuiting of builds in the event of a job failure? I know i can kind-of make it work if i do “propagate = false” while running the build step but that kills the failFast feature, and i need that.

For example, below is my code and i want the value of variable achild_job_info inside the catch block as well.

  • sonar maven plugin build error, SonarQube version: null
  • Changing Jenkins build number
  • QTP to Jenkins integration help need CI
  • Jenkins Multibranch pipeline: What is the branch name variable?
  • Sending Keys to Input WebElement fails as it is not an absolute path
  • Integrating SourceMonitor into a Jenkins CI-System
  • build_jobs = [“Build_A”, “ Build_B”, “ Build_C”]
    
    def build_job_to_number_mappings = [:]
    // in this hashmap we'll place the jobs that we wish to run
    def branches = [:] 
    def achild_job_info = ""
    def abuild_number = ""
    for (x in build_jobs) {
        def abuild = x 
        branches[abuild] = { 
            stage(abuild){
                retry(2) {
                    try {
                        achild_job_info = build job: abuild
                        echo “ achild_job_info”  // —>  this gives: org.jenkinsci.plugins.workflow.support.steps.build.RunWrapper@232601dc
                        abuild_number = achild_job_info.getId()
                        build_job_to_number_mappings[abuild] = achild_job_info.getNumber()
                    } catch (err) {
                        echo “ achild_job_info: ${achild_job_info } “  // —> This comes empty. I want the runwrapper here as well, just like in the try block. 
                        abuild_job_number = abuild_job_info.getId()
                        build_job_to_number_mappings[abuild] = achild_job_info.getNumber()
                    } // try-catch
            } // stage
       } // branches
    } // for
    branches.failFast = true
    parallel branches
    

  • git submodules not updating in Jenkins build
  • How to log into git bitbucket repository from jenkins
  • When building only a subdirectory of a Git repo, Jenkins shows the changes of the whole repo - why?
  • Jenkins docker agent in declarative pipeline: file not found
  • Is there any way to change the working directory of a Jenkins Maven build?
  • Permission denied (public key) during fetch from GitHub with Jenkins user on Ubuntu
  • One Solution collect form web for “jenkins pipeline catch build_job info for a failed parallel build”

    The only way i could find out for now is to use the value of the ‘exception string’ and split it to get the current build number and name. I am not sure that is the most robust way to do this but works for now. Posting this reply to help others.

    Git Baby is a git and github fan, let's start git clone.