It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Pull Request Pipeline: Add a new build.

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

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

@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
Community showcase
Published in Bitbucket Pipelines

What We Learned When We Researched Open Source Vulnerabilities in 7 Popular Coding Languages

...hey are a part of us, shaping how we interact with the world around us. The same holds true for programming languages when we think about how different kinds of vulnerabilities raise their heads in t...

1,042 views 0 3
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you