Bitbucket does not offer an overview of a team's repo pipeline build statuses. I think this is crucial if you have a lot of repositories and you want to see which builds are failing. Clicking through each repository is a nightmare.
I asked that question here:
There is no solution, so to resolve the issue I wrote a script that highlights the status of the build with the highest number:
# Requires `curl` and `jq`
# Goes something like this:
echo -n $repo pipeline state:
pipelineStatus=$(curl -s -u <BITBUCKET_CREDENTIALS> -H 'Content-Type: application/json' 'https://api.bitbucket.org/2.0/repositories/$account/$repo/pipelines/?pagelen=100' | jq '.values |max_by(.build_number) |.state.result.name')
if [[ "$pipelineStatus" =~ FAIL ]]
then
echo -e "\e[0;31m\e[1m"$pipelineStatus"\e[0m"
else
echo $pipelineStatus
fi
`pagelen` is required to ensure that we get more than 10 builds listed. They're listed OLDEST to NEWEST, e.g. 1 -> 10.
The problem is that even with `pagelen` set to 100 eventually it'll tail off after 100 builds. And besides we're really only really interested in max(build_number) - we don't need all the other content.
A solution to get the most recent build via API would be ideal (i.e max(build_number))
However, without that, can we use sorting? So we could sort it like:
# Adding this to the API request does not work:
?pagelen=1&sort=-build_number
# the error is
# {"error": {"message": "Bad request", "data": {"arguments": {}, "key": "rest-service.rest-service.invalid-sort-attribute"}, "detail": "Invalid sort attribute provided 'build_number'"
Then we would only need `pagelen=1` because we'd have the highest build_number.
Hi Douglas,
You could try sorting with created_on. For example:
'https://api.bitbucket.org/2.0/repositories/$account/$repo/pipelines/?pagelen=1&sort=-created_on'
That will get you the latest build for that repository.
We currently don't have support for ordering by build_number at the moment. So created_on will need to be used instead.
Thanks,
Phil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.