Uploaded image for project: 'Bamboo Data Center'
  1. Bamboo Data Center
  2. BAM-21991

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

    • Icon: Suggestion Suggestion
    • Resolution: Unresolved
    • None
    • API
    • None
    • 0
    • 1
    • Our product teams collect and evaluate feedback from a number of different sources. To learn more about how we use customer feedback in the planning process, check out our new feature policy.

      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
      

       

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

                Created:
                Updated: