Hello,Is there a way to know inside a pipeline script, if the last pipeline for this branch was a success?
Thanks
Hello @Ilan Hazan,
I don't think there's any other way to get such information but making a REST API call. The /pipelines endpoint supports filtering by branch using target.branch query parameter, this endpoint is used by Pipelines UI.
For example, this returns a list of pipelines for branch master, for each pipeline there will be its target commit, selector and state (I decoded this URL to make it easier to read):
https://api.bitbucket.org/2.0/repositories/<workspace>/<repository>/pipelines/?fields=values.target.*,values.state.*,page,size&page=1&pagelen=10&sort=-created_on&target.branch=master
Note that first item will be the in-progress pipeline which is making the REST call.
If your repository is private you'll obviously need to make some additional configuration to make such REST API call from your pipeline.
Hope this helps.
Cheers,Daniil
Many thanks @Daniil Penkin
Hello,By the docs the suggested command is triggering new pipeline. What I am missing?
Hi @Ilan Hazan
I guess you're looking at the POST method for that endpoint – it indeed triggers a pipeline.
There's also a GET method (make sure you're on the right tab) which is used to find pipelines (browse history, essentially).
It looks like you're new here. Sign in or register to get started.