Skip to content

Checking your reading list…

Retry verification

Stay curious. Build better.

Appearance

Choose how BestHub looks on this device.

Changes apply immediately.

Search articles

Open Discover with these filters

Suggested searches

Using Jenkins Generic Webhook Trigger to Capture Bitbucket Pull Request Events
Operations 4 min read

Using Jenkins Generic Webhook Trigger to Capture Bitbucket Pull Request Events

This guide explains how to configure a Bitbucket webhook and a standard Jenkins job with the generic‑webhook‑trigger plugin to automatically receive pull‑request events, extract the PR ID, and trigger downstream actions without relying on a multi‑branch pipeline job.

This article explains how to use the Jenkins generic-webhook-trigger plugin to capture Bitbucket repository events such as Pull Request IDs.

While a Multi‑branch Pipeline job can expose PR information via environment variables, creating such a job often requires cloning the repository and is not the most efficient approach.

Instead, you can set up a regular Jenkins job to receive Bitbucket webhook events. First, create a Bitbucket webhook with a name (e.g., test-demo) and a URL like

http://JENKINS_URL/generic-webhook-trigger/invoke?token=test-demo

. The webhook can be configured under the “Webhooks” or “Post Webhooks” section.

Next, configure the Jenkins job to use the generic‑webhook‑trigger plugin, specifying the same token ( test-demo) so the webhook payload is accepted. In the pipeline script, add a line such as echo pr_id is ${pr_id} to output the received Pull Request ID.

To test, create a Pull Request in the monitored Bitbucket repository. The webhook triggers the Jenkins job, which runs the pipeline and prints the PR ID in the console log, confirming that the event data was successfully captured.

With the PR ID available, you can invoke additional scripts or services—such as calling the Bitbucket REST API—to retrieve detailed PR information, analyze changed files, link Jira tickets, or automate review and regression testing.

About this article

For questions about attribution, corrections or content rights, please contactadmin@besthub.devand we will review it promptly.

Report an issue with this article
CI/CDautomationJenkinsWebhookBitbucket

Reader feedback

Was this useful?

Useful0

Discussion 0

Questions, practical examples and thoughtful responses.

Open full discussion