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

Pull Request Pipeline: Add a new build.

T. Klingenberg October 21, 2019

I would love to add another "build" on my own from within a pipeline.

On a pull request, the UI shows on the right top hand a summary of the builds (e.g. "3 of 3 passed")  image.png

 

When clicking, there is more detail:

 

image.png

Builds number one and two are created by Bitbucket Cloud Pipelines Plugin itself for tow piplines: Pull Request and Branch.

Build number three is from a remote service, here SonarCloud.

Similar to what SonarCloud does here, I would like to learn which APIs there are to create a build entry here from within my pipelines.

I've looked into the REST API but was a bit lost as I couldn't find anything useful. Maybe this is for Webhooks? But then I didn't know where to find Webhooks (and I guess these are the other way round).

Any pointers would be great. I can imagine it's as easy as just firing some curl calls.

 

1 answer

1 accepted

0 votes
Answer accepted
mkleint
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 22, 2019
T. Klingenberg October 23, 2019

Thanks for the hint, this looks promising, I'll mark it as answer and hope I can give more feedback soon.

T. Klingenberg October 28, 2019

@mkleint  Thanks for your answer, this works like a charm after I found out I had an issue with the JSON payload.

 

/edit: Here an example curl I use. I also tried w/o any request body:

 

curl -X POST -ivs -u "${BITBUCKET_API_USER}:${BITBUCKET_API_PASSWORD}" \
-H 'Content-Type: application/json' \
"https://api.bitbucket.org/2.0/repositories/${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}/commit/${REVISION}/statuses/build" \
-d '
{
"key": "merge-ci-build",
"state": "INPROGRESS",
"name": "Merge CI Build",
"description": "Description text of the merge CI build"
}'

 

The ${REVISION}  is an existing reference. I already use it to identify the pull request which caused the build on the merge successfully via the API. Can be the full hash or shortened.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events