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.

Bitbucket events not registered automatically

See original GitHub issue

Your checklist for this issue

  • Jenkins version 2.240.5

  • Plugin version 2.7.0

  • Bitbucket cloud

  • Bitbucket server and version 6.7.3

Description

Hi, We are trying to upgrade to the latest version of jenkins lts and after upgrade the bitbucket-branch-source-plugin does not register proper webhook events. The webhook gets registered;however, no Pull requests/Repository events are selected on the Bitbucket side. Only when we manually select on merge, on pull request, etc does the webhook trigger and kicks off the build accordingly. This is problematic because we are dealing with quite a large number of repositories. We are using the post-webhooks for Bitbucket (2.3.15) plugin.

The project jobs have been configured based on plugins documentation. Are we missing something or is this a bug?

Thanks

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:22 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
george2515commented, Apr 9, 2020

There is nothing suspicious in the Bitbucket logs. Webhook registers just fine. We have tested the Post Webhook plugin’s API on Bitbucket side and we were able to register a webhook with properly configured events through their API. For anyone that is interested here is the link to docs:

https://moveworkforward.atlassian.net/wiki/spaces/DOCS/pages/867205121/Atlassian+Bitbucket+Post+Webhook+API

All of this leads me to believe the payload this plugin is posting over to Bitbucket is incorrectly set under certain circumstances so I would start my investigation there.

For anyone that is experiencing the same problem, we explicitly disabled this plugin’s hook management and added a temporary stage to our pipelines that filters through webhooks based on registered URL and either updates an existing webhook with proper events or creates a new webhook with the same events. Needless to say, events configured correspond to the types of pipelines (PR build/Branch build/Release build, etc).

1reaction
ryanwoodsmallcommented, May 19, 2020

The REST API can be used to enable events for existing hooks. cURL example is below, some info elided; the first does a GET of the existing hook, the second does a POST to the specific endpoint (the id from the JSON) of the hook config using an access token. You need:

  • the id (appended to the REST URL for the specific config you want to update)
  • the title (cannot be NULL)
  • the url (cannot be NULL)
  • the element to change (tagCreated here)
$ curl -k -L -s \
  -X GET \
  -H "Authorization: Bearer ${TOKEN}" \
  -H "Content-Type: application/json" \
    http://${SITE}/rest/webhook/1.0/projects/${PROJ}/repos/${REPO}/configurations | jq .
{
  "id": 65,
  "title": "Jenkins hook",
  "url": "...",
  ...
  "tagCreated": false,
  ...
}
$ curl \
  -k -L -s \
  -H "Authorization: Bearer ${TOKEN}" \
  -H "Content-Type: application/json" \
  -X POST \
  -d '{"title": "Jenkins hook", "url": "...", "tagCreated": "true"}' \
    http://${SITE}/rest/webhook/1.0/projects/${PROJ}/repos/${REPO}/configurations/65 | jq .
{
  "id": 65,
  "title": "Jenkins hook",
  "url": "...",
  ...
  "tagCreated": true,
  ...
}

Cloudbees has some Jenkins docs with examples here: https://support.cloudbees.com/hc/en-us/articles/115000083932-Generate-webHooks-in-Bitbucket-Server-via-REST-API-for-Pipeline-Multibranch#updateawebhookbyid

Read more comments on GitHub >

github_iconTop Results From Across the Web

Responding to application events - Atlassian Developer
Ensure that an instance of your class is registered with the EventPublisher . Starting from version 4.7, Bitbucket will automatically scan ...
Read more >
Bitbucket Webhooks Troubleshooting
In Jenkins for non-multibranch jobs, you are either using the Git Plugin, ... Jobs are not automatically triggered when a changes are pushed...
Read more >
BitBucket branch create and delete events fired multiple times
While testing branch events I noticed that delete and create events are fired more than once (I am not listening to the BranchChangedEvent)....
Read more >
Build Bitbucket Cloud repositories - Azure Pipelines
Your Bitbucket Cloud users do not automatically get access to Azure ... since that identity is used to register a webhook in Bitbucket....
Read more >
Bitbucket Push and Pull Request - Jenkins Plugins
Bitbucket Push And Pull Request Plugin will not work if the old Bitbucket plugin https://plugins.jenkins.io/bitbucket is still installed.
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