I would like to know if there is a running bitbucket pipeline. To do that, I'm trying to get all pipelines with the status "in progress", using the API.
I found the query to list all pipelines here. And I've found this answer on the forum, using the filtering tools spec here but I can't make it work.
I've tried this very simple query:
curl --request GET \
--url 'https://api.bitbucket.org/2.0/repositories/<myWorkspace>/<myRepository>/pipelines?status!=COMPLETED' \
--header 'Authorization: Bearer <myToken>' \
--header 'Accept: application/json'
{
"page": 1,
"values": [
{
"uuid": "{xxxxxxxxxxxxxx}",
"repository": {
...
},
"state": {
"name": "COMPLETED",
...
I've also tried by providing the full path to the "name" property without success.
curl --request GET \
--url 'https://api.bitbucket.org/2.0/repositories/<myWorkspace>/<myRepository>/pipelines?state.name!=COMPLETED' \
--header 'Authorization: Bearer <myToken>' \
--header 'Accept: application/json'
What am I doing wrong?
Hi and welcome to the community!
The not equal operator will not work with the status field. Additionally, COMPLETED is not an available status.
These are the pipelines statuses, as my colleague mentioned in the question you linked:
Successful: status=PASSED,SUCCESSFUL
Failed: status=FAILED,ERROR
Running: PENDING,BUILDING,IN_PROGRESS
Paused: status=PAUSED,HALTED
Stopped: status=STOPPED,SKIPPED
You should be able to get the running pipelines with an API call like the following:
curl -u bitbucket_username:app_password -X GET https://api.bitbucket.org/2.0/repositories/<workspace>/<repository>/pipelines/?status=PENDING&status=BUILDING&status=IN_PROGRESS
Does this work for you?
Filtering by state or state.name is also not supported at the moment:
Kind regards,
Theodora
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.