4

Not getting Build job details/status of the PR when using Bitbucket API for any pull request

Here is my API URL:

https://example.com/rest/api/1.0/projects/{projectkey}/repos/{reposlug}/pull-requests/{pullrequestID}

How Build status looks like on GUI:

enter image description here

I also tried below methods to get the Build status but no luck

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/settings/pull-requests
/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/settings/hooks

So I wanted to get whether build status of any PR whether it is Success or Fail

Thanks in Advance for your answers.

2 Answers 2

11

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

Sign up to request clarification or add additional context in comments.

Comments

3

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}'

1 Comment

if you're on a server/data-centre instance you would be stuck to API v1.0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.