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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Get pipelines filtering on target.selector.type not working

Edited

I have an API query that I believe was working before but now is not filtering as expected.  I am trying to get pipelines but filter out any custom pipelines (just default), so I am using:

https://api.bitbucket.org/2.0/repositories/<workspace>/<repo>/pipelines/?sort=-created_on&target.branch=develop&target.selector.type=default

However this is now returning pipelines with target.selector.type="custom" as well. 

I have also tried the following but still getting back custom pipelines as well:

https://api.bitbucket.org/2.0/repositories/<workspace>/<repo>/pipelines/?q=target.selector.type+%3D+%22default%22&sort=-created_on&target.branch=develop

Did something change, or am I doing something wrong (perhaps this was never working as expected?)

1 answer

0 votes

Hi Jay,

I am not sure if something has changed recently, but I believe that the following should return all builds on develop branch (and no custom builds):

http://api.bitbucket.org/2.0/repositories/<workspace>/<repo-slug>/pipelines/?target.ref_name=develop&sort=-created_on

Is this something that works for you?

Kind regards,
Theodora

@Theodora Boudale That answer got caught up in my junk filter, just happened to see it today.  I tried that, but it didn't work.  I also tried 

/pipelines/?q=+%3D+%22target.ref_name=develop%22&sort=-created_on

but that completely ignores target.ref_name and returns the master branch results actually. 

Hi @Jay Seletz ,

The part of the URL you posted here won't work, you don't need the 'q=' or double quotes there.

A curl command like the following returns builds that ran on branch develop for me:

curl -X GET -u username:app-password https://api.bitbucket.org/2.0/repositories/workspace-id/repo-slug/pipelines/?target.ref_name=develop

after replacing appropriate values for username, app-password, workspace-id and replo-slug.

Could you please let me know

  1. What is the exact URL you are using? (feel free to sanitize workspace-id and repo-slug)
  2. Could you give us some more info on what exactly is happening if you execute that?
    Do you get an error in the output, and if so, what error?

Kind regards,
Theodora

Hi @Theodora Boudale - I did try the exact url you suggested, and while it does filter on branch correctly, the results returned also include custom pipeline runs, e.g. 

"selector": {
"pattern": "build-all",
"type": "custom"
}

I am trying to query by target branch AND selector.type=default.  When I say the two approaches I've tried (without using "q=" syntax and with it), it succeeds and returns results filtered by branch, but not by type at all, when specifying

http://api.bitbucket.org/2.0/repositories/<workspace>/<repo-slug>/pipelines/?target.ref_name=develop&sort=-created_on

Also with the two examples I posted originally when I started this thread, the results are not filtered by type, just by branch.  I believe this first url I posted (at the top of this thread) used to correctly filter by type, but no longer does, nor does any other query syntax I've tried.

Hi @Jay Seletz , thank you for your reply and explanation.

I wasn't thinking about custom builds that ran on a branch, I had in mind only custom builds that ran on a specific commit which are excluded if you specify a branch. I see what you're saying about target.selector.type not working in the filter.

I will reach out to the dev team about this issue and will get back to you as soon as I have a response.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Apps & Integrations

🍻🍂Apptoberfest Update: Upcoming Virtual Events 🎉

Hello Community! I hope you've been enjoying the 🍂Apptoberfestivities🍂 (I know I have!) The event is heating up next week with a series of virtual events that we're calling the 🍻🍂Partner App ...

111 views 1 8
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you