0

I am running the following stage from upstream job. How to get the return status code of the downstream job - UI_TEST_PIPELINE.
I need to get the status code like '0' or '1' based upon its execution and perform some validation. Please share the info.

stage('Run_UI_TEST') {
   steps {
       script {
           last_started = env.STAGE_NAME
           def UI_TEST_PIPELINE_job_info = build(
           job: "UI_TEST_PIPELINE",
           parameters:[  
                  string(name: 'RELEASE_VERSION', value: 'main'),
                  string(name: 'ENVIRONMENT', value: 'CI/CD'),
                  string(name: 'URL', value: "http://${env.HOSTNAME}:8001/ui"),
                  string(name: 'SUITE_PATH', value: '"Test Suites/QASuite/TestSuite'),
                  string(name: 'EMAIL_LIST', value: 'qa_all_grp@domain.com'),
                  string(name: 'EMAIL_SUBJECT', value: "UI PIPELINE - $VAR"),
                  string(name: 'USER_NAME', value: 'admin'),
                  string(name: 'PASSWORD', value: 'welcome1')
           ])                 
        }
    }
}
Noam Helmer
  • 5,310
  • 1
  • 9
  • 29
Saro
  • 11
  • 5

1 Answers1

0

You can get current result from the job info.

def result = UI_TEST_PIPELINE_job_info.getClass().getCurrentResult()

Based on the current result (SUCCESS, FAILURE, ABORTED) you can perform validation.

See also https://stackoverflow.com/a/51105617/10721630

Melkjot
  • 498
  • 3
  • 13