Need to get last successful commit ID via V2 API

Hello,
I want to get the commit id of last successful pipeline build on a specific branch via V2 api,
Can anyone please help me ?

I found one similar answer :
https://circleci.com/api/v1.1/project/github/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME?filter=successful&limit=1

But the problem here is:-
i) I cant filter it for a specific branch
ii) It is api v1.1 (I think I should be using v2)

Thanks.

Hi,

Filter option is currently not available in API v2. You can use “Get all pipeline” endpoint to get the information about all the pipelines and it also contains the branch.

Regards,
Pawan

Hi Pawan,
Are there any plans to add filter to API v2 ?

Also, is there any alternative other than parsing all pipelines and getting last successful build’s commit id for a branch?

If my CI system can’t give me my last successful commit id easily then it completely defeats the purpose of having a CI system right ?

Hi,

Sorry but currently that is the only option and we don’t have any direct endpoint showing last successful job. I am sure our engineering team will be working on it.

I agree with you and would like you to vote to this idea which looks similar to yours.

Regards,
Pawan