Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to get latest pipelines from API

Deleted user July 4, 2022

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?

1 answer

1 accepted

0 votes
Answer accepted
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 5, 2022

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 

Deleted user July 5, 2022

Thank you!

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events