I have a webhook that will trigger Jenkins build when there is a new or updated pull requests for the repos.
It will trigger the bitbucket notification to show the build status.
However, when the PR has multiple updates, it will trigger multiple builds that are tied to the PR. This is a problem as if any of the builds fails or never completes for a reason, the PR is stuck as there is a branch restriction set:
"Check the last commit for at least 1 successful build, no failed builds, and no in progress builds"
ie.
4 builds were successful after the 1st build got stuck in a never completed state. This prevented the PR from being merged
This PR has 6 builds that were unsuccessful, but the last one is successful. However, since it doesn't pass the PR requirements for merging:
"Check the last commit for at least 1 successful build, no failed builds, and no in progress builds"
It is not allowed to merge.
I am using the bitbucketStatusNotify function, passing in buildState, reposSlug, and commitID.
ie.
bitbucketStatusNotify(buildState: "SUCCESS", repoSlug: "my-repos", commitId: "xyzzy")
Is there a way to cancel previous build states and only have the latest one tied to the PR?
Thanks.
Hi Jimmy,
You can get info about the commit statuses (including their key) of a certain commit with the following API endpoint:
Example call:
curl -u username:app-password --request GET \
--url 'https://api.bitbucket.org/2.0/repositories/workspace-id/repo/commit/7c47933/statuses' \
--header 'Accept: application/json'
You can then use the following API endpoint to update a certain status:
Example call:
curl -u username:app-password --request PUT \
--url 'https://api.bitbucket.org/2.0/repositories/workspace-id/repo/commit/7c47933/statuses/build/some-key' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
"state": "SUCCESSFUL"
}'
You can see all available values for state in the last link I shared if you select + Show child properties for Commit Status > expand the state property.
Please feel free to let me know if you have any questions!
Kind regards,
Theodora
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I found there is a buildKey field that is unique for the link.
https://github.com/jenkinsci/bitbucket-build-status-notifier-plugin
Is there a way to find the buildKey value for previous builds? Knowing this value, I can change the build state of the existing builds linked to the PR.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.