如何通过PR评论结合Post Webhooks for Bitbucket触发Jenkins多分支任务
Got it, let's walk through exactly how to set this up so your task runs only when someone comments "run this again" on a Bitbucket PR using the Post Webhooks for Bitbucket plugin.
Step 1: Enable the Comment Event
First, confirm you’ve toggled on the Pull request commented option in your webhook configuration (you mentioned you spotted this, so just make sure it’s enabled alongside your existing "created" and "re-scoped" events).
Step 2: Add a Payload Filter for Target Comment Text
The magic here is filtering the webhook to only fire when the comment matches your exact phrase. Most versions of this plugin include a Payload Filters or Conditions section where you can define rules based on Bitbucket’s webhook JSON payload.
Here’s the exact filter setup you need:
- In your webhook settings, find the "Payload Filters" section and add a new rule.
- Set these values:
- Path:
comment.content.raw(this targets the unformatted raw text of the PR comment in Bitbucket’s payload) - Operator:
Contains(useEqualsif you want an exact, case-sensitive match; "Contains" works for slight variations like extra spaces) - Value:
run this again(your target comment trigger phrase)
- Path:
Step 3: Verify the Payload Path (Optional)
If you’re unsure about the payload path, you can capture a test payload using a webhook testing tool or by checking your task runner’s logs. Look for the comment object in the JSON response—you’ll see the raw comment text under content.raw.
Step 4: Test the Setup
Create a test PR, leave a comment with "run this again", and check if your task triggers. If it doesn’t, double-check:
- The filter path is spelled correctly (case sensitivity might matter depending on your plugin settings)
- The "Pull request commented" event is still enabled
- Your task runner is properly listening for the webhook signal
Example Rule (Visual Builder Version)
If your plugin uses a drag-and-drop rule builder, it might look like this:
IF
comment.content.rawCONTAINSrun this againTHEN trigger webhook
That’s all you need! This setup ensures the webhook only sends a trigger when your specific comment phrase is used, rather than firing on every PR comment.
内容的提问来源于stack exchange,提问作者felixliljb

