question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug: Double PR Builds - Remove Unneeded PR Hook Event Types

See original GitHub issue

Your 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.

  1. Create a bitbucket project and a repo named test that are hooked up to Jenkins with a multibranch pipeline job that builds PRs
  2. Install the code owners plugin on bitbucket server
  3. Define CODEOWNERS in the code owners file at root of the repo
  4. 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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ryancurrahcommented, Sep 15, 2020

Hey @bitwiseman im waiting for our Jenkins team to deploy it still.

1reaction
bitwisemancommented, Sep 8, 2020

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using repository hooks | Bitbucket Data Center and Server 8.6
Bitbucket supports two types of hooks, pre-receive and post-receive hooks. ... PostRepositoryHooks, which gets called for both PR merge and post-receive.
Read more >
Webhooks - GitLab Docs
In your project or group, on the left sidebar, select Settings > Webhooks. ... Corresponds to event types but in the format "<EVENT>...
Read more >
Bug listing with status RESOLVED with resolution FIXED as at ...
Bug :2 - "How do I attach an ebuild. ... Bug:2014 - "Balsa-1.2.4 build still fails -- two more fix suggestions" status:RESOLVED resolution:FIXED...
Read more >
Service hooks events - Azure DevOps | Microsoft Learn
Available event types. Build and release. Build completed; Release created; Release abandoned; Release deployment approval completed; Release deployment ...
Read more >
My create-react-app is failing to compile due to ESLint error
To completely disable eslint on a production build, add this to your ... Remove "eslint" from dependencies and/or devDependencies in the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found