Bug: Double PR Builds - Remove Unneeded PR Hook Event Types
See original GitHub issueYour checklist for this issue
-
Jenkins version
-
Plugin version
-
Bitbucket server and version
Description
Jenkins version: 2.235.2.3 Plugin version: 2.9.1 Bitbucket server and version: 5.x
When creating a Pull Request through the API Jenkins will build the PR twice. When I remove the hook event types SERVER_PULL_REQUEST_MODIFIED
and SERVER_PULL_REQUEST_REVIEWER_UPDATED
from the auto configured web hook it no longer starts two PR builds at once when creating a new PR.
We do use the CODEOWNERS plugin as well which adds reviewers to the PRs after the PR is created and adds a comment to the PR with why they were added: https://marketplace.atlassian.com/apps/1218598/code-owners-for-bitbucket-server. Which is most likely why it’s being triggered twice, interestingly enough it does not trigger a double build when creating a PR through the UI. This is because the UI does some pre-populating of PR reviewers that the API call does not.
Note that this behavior did not occur on plugin versions prior to 2.9.0
.
My suggestion is to remove these hook event types as it does not make sense to fire a build off of them.
Below is how you can reproduce this issue.
- Create a bitbucket project and a repo named
test
that are hooked up to Jenkins with a multibranch pipeline job that builds PRs - Install the code owners plugin on bitbucket server
- Define
CODEOWNERS
in the code owners file at root of the repo - Execute the
curl
command below to create a PR through the API
export BITBUCKET_TOKEN="MyT0Ken"
export BITBUCKET_URL="http://127.0.0.1:7990"
export BITBUCKET_PROJECT_KEY="test"
export GIT_REPOSITORY="test"
export GIT_BRANCH="my-test-branch"
export PR_TITLE="my test pr title"
export PR_DESCRIPTION="my test pr desc"
export PR_DST_BRANCH="master"
curl --fail -sS --retry 3 --retry-connrefused --retry-delay 3 -H "Authorization: Bearer ${BITBUCKET_TOKEN}" -H "Content-Type: application/json" "${BITBUCKET_URL}/rest/api/1.0/projects/${BITBUCKET_PROJECT_KEY}/repos/${GIT_REPOSITORY}/pull-requests" --data '{"title": "${PR_TITLE}", "description": "${PR_DESCRIPTION}", "fromRef": {"id": "refs/heads/${GIT_BRANCH}", "repository": {"slug": "${GIT_REPOSITORY}", "name": null, "project": {"key": "${BITBUCKET_PROJECT_KEY}"}}}, "toRef": {"id":"refs/heads/${PR_DST_BRANCH}", "repository": {"slug": "${GIT_REPOSITORY}", "name": null, "project":{"key": "${BITBUCKET_PROJECT_KEY}"}}}}' | jq -r '.links.self[0].href'
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (2 by maintainers)
Top GitHub Comments
Hey @bitwiseman im waiting for our Jenkins team to deploy it still.
@ryancurrah This problem is address by branch-api-plugin v2.6.0 in “[JENKINS-54052] Honor quietPeriod on children of multibranch pipeline job @g-doc (#190)”. Please update and comment if the problem still occurs.