-
Suggestion
-
Resolution: Unresolved
-
None
-
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
- derived from
-
BAM-21420 The result/branch API should work for the default branch
- Gathering Interest
I’m writing some auto-scaling logic for my Selenium grid in AWS. I want to regularly check the running jobs in Bamboo so that I can pre-scale my grid based on upcoming demand. Most of our jobs tend to be on feature branches, so they need to be included in the response. The provided workaround is too slow and inefficient for my purposes due to the hundreds if not thousands of REST API calls required.