I'm trying to get the latest pipelines running on a repo via API, but its only returning the pipelines that were first built.
I know that if I specify the UUID of a specific pipeline, it returns the required info that I'm trying to get, but I'm writing a script and manual UUID assignment is not possible.
Do you guys know what I could do so that I'd get the latest pipelines running?
Hello @[deleted] ,
Welcome to Atlassian Community!
The Bitbucket public API offers sorting/querying capabilities so you can organize the results of the API accordingly to what best fits your use case.
In this case, if you want to order the results returned by the pipeline's endpoint accordingly to created_on date (more recent first), you can use the following example :
curl -X GET -u bitbucket_username:app_password "https://api.bitbucket.org/2.0/repositories/<workspace>/<repository>/pipelines/?sort=-created_on"
This will sort the results based on the field created_on in descending order (because of the hyphen).
You also have the option to combine both querying and sorting, as in the below example :
curl -X GET -u bitbucket_username:app_password "https://api.bitbucket.org/2.0/repositories/<workspace>/<repository>/pipelines/?status=PENDING&status=BUILDING&status=IN_PROGRESS&sort=-created_on"
This will query for only the pipelines that are in the status considered "in progress", and sort the results based on created_on date.
The following pipeline statuses are available for querying/filtering :
Successful: status=PASSED,SUCCESSFUL Failed: status=FAILED,ERROR Running: PENDING,BUILDING,IN_PROGRESS Paused: status=PAUSED,HALTED Stopped: status=STOPPED,SKIPPED
Hope that helps! Let me know in case you have any further questions.
Kind regards,
Patrik S
Thank you!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.