IBM Cloud Docs
Using the Stage Results API in custom scripts

Using the Stage Results API in custom scripts

You can use the Stage Results API to access the results of specific stages and custom stages. This API can only be used in your custom scripts.

Customize your output to view the desired output in your Stage results. Use the following code snippets to generate various kinds of output:

  1. Type get_data result to print which stages have saved results.

       $ get_data result
       test
       detect-secrets
       branch-protection
    
  2. Type get_data result <stage-name> to print the result for a specific stage.

       $ get_data result detect-secrets
       success
       $ get_data result test
       failure
    
  3. Iterate through the saved results:

       #!/usr/bin/env bash
       while read -r stage; do
             result=$(get_data result $stage)
             echo "The result of '$stage' stage is: '$result'"
       done < <(get_data result)
    

On running the snippet in you console , the following output is generated:

  ```text {: screen}
     The result of 'detect-secrets' stage is: 'success'
     The result of 'branch-protection' stage is: 'success'
  ```