The Bamboo /result API endpoint should return information from Plan branch builds

XMLWordPrintable

    • Type: Suggestion
    • Resolution: Unresolved
    • None
    • Component/s: API
    • None
    • 0
    • 1

      Problem Definition

      When using the /result REST API endpoint, only results from the default branch are returned

      Suggested Solution

      Allow the /result REST API to also return Plan branches results by default or by using an expand property

      Workaround

      To retrieve all results from all Default Branches and Plan branches together, run the following script:

      #!/bin/bash
      ## Declare Curl options, credentials and URL
      CURLOPTS=( "-s" "-k" "-H" "Accept: application/json" "-u<username>:<password>" )
      BAMBOO_URL="https://bamboo.mydomain.net"
      
      ## You may have to adjust max-results
      REST_OPTS="?includeAllStates=true&max-results=25"
      
      # Create a list of default Plans
      PLANS=$(curl "${CURLOPTS[@]}" "${BAMBOO_URL}/rest/api/latest/plan${REST_OPTS}" \
                | jq -r '.plans.plan[].key')
      
      # Create a list of plan branches
      PLAN_BRANCHES=$(for p in ${PLANS} ; do
                        curl "${CURLOPTS[@]}" "${BAMBOO_URL}/rest/api/latest/plan/${p}/branch${REST_OPTS}" \
                          | jq --arg PLAN "${p}/" -r '$PLAN + .branches.branch[].shortName' ;
                      done)
      
      # Print both default and branch results
      curl "${CURLOPTS[@]}" "${BAMBOO_URL}/rest/api/latest/result${REST_OPTS}" | jq '.results.result[]'
      for PB in ${PLAN_BRANCHES} ; do
        curl "${CURLOPTS[@]}" "${BAMBOO_URL}/rest/api/latest/result/${PB%/*}/branch/${PB#*/}${REST_OPTS}" \
          | jq 'select(.results.size > 0) | .results.result[]';
      done
      

       

            Assignee:
            Unassigned
            Reporter:
            Eduardo Alvarenga (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: