Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Rest API filter tags

Rio De Sousa June 29, 2023

Hi there! 

All of my commits into main are tagged with their build number. eg build-1.0.2589

My prod env will always be a few commits behind dev, as new features get tested.
So for eg. prod = build-1.0.2539 and dev = build-1.0.2583. I am trying to get all the tags that are between prod and dev. So something like this:

https://api.bitbucket.org/2.0/repositories/{workspace}/{repo}/refs/tags?q=name>="build-1.0.2539"&sort=-name

Which should ideally return all those tag objects between dev and prod. Perhaps I should be filtering by date rather?

Thank you! 

2 answers

1 accepted

0 votes
Answer accepted
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 30, 2023

Hi Rio and welcome to the community!

You can filter by name with the operators >= will like this:

https://api.bitbucket.org/2.0/repositories/{workspace-id}/{repo}/refs/tags?q=%28name+%3D+%22build-1.0.2539%22+OR+name+%3E+%22build-1.0.2539%22%29

The query, without URL encoding, is (name=build-1.0.2539 OR name>build-1.0.2539)

Please keep in mind though that the name is a string and not a numeric value. If we assume that only the last 4 digits of the tag's name change, filtering like this should give you what you want up until the tag build-1.0.9999.

When you reach the tag build-1.0.10000 and the name in the API query is e.g. build-1.0.9960, then the API query won't return the tag build-1.0.10000.

Filtering by date sounds better for what you want to achieve, but it would need to be done on client side as this endpoint does not support filtering by date at the moment. We have a feature request that you can vote for to express your interest:

Kind regards,
Theodora

Rio De Sousa June 30, 2023

Hey Theodora. Yeah I think it makes much more sense to do the filtering on my end. Thanks for the help! All the best

0 votes
Rio De Sousa June 30, 2023

Another option would be to just do the filtering on the client side, if there is no other way to do it through the url.

Suggest an answer

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

Atlassian Community Events