How to get build status of PR using BitBucket API? How to get build status of PR using BitBucket API? jenkins jenkins

How to get build status of PR using BitBucket API?


The build status is on the commit, not on the PR. First you should find the latest commit of the source branch by calling /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}. see the docs for more details

Once you have the commit id you can query the build-status api by calling /rest/build-status/1.0/commits/{commitId}. See the docs for more details


Using API 2.0

Example:

curl --request GET \  --url https://api.bitbucket.org/2.0/repositories/piavita/com.piavita-vet.ios/pullrequests/300/statuses \  --header 'Authorization: Basic SecretKey' \  --header 'Content-Type: application/json'
curl --request POST \  --url https://api.bitbucket.org/2.0/repositories/piavita/com.piavita-vet.ios/commit/8619291af393/statuses/build \  --header 'Authorization: Basic SecretKey' \  --header 'Connection: keep-alive' \  --data '{\n   "url": "http://jenkins.ddns.net:8080/job/jobName/123/",\n   "state": "SUCCESSFUL",\n    "key": "JENKINS"\n}'