You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

自建Bamboo实例配置:仅当Pull Request目标分支匹配正则时触发计划分支创建

Solution: Filter Branches at the Trigger Layer to Avoid Pipeline Bloat

Got it, let's tackle this problem properly—since you don't want to clutter your Bamboo pipelines with conditional tasks and need zero builds for non-matching PRs, the key is to filter at the trigger level instead of inside the pipeline itself. This way, non-qualifying PRs won't even send a build request to Bamboo, which exactly matches your requirement.

BitBucket's webhooks support built-in condition expressions that let you restrict which PRs send trigger requests to Bamboo. This is the cleanest approach because it stops unwanted triggers before they ever reach your Bamboo instance.

Here's how to set it up:

  • Go to your BitBucket repo's Settings > Webhooks
  • Either edit your existing Bamboo webhook or create a new one
  • Scroll to the Trigger conditions section and add a new condition:
    • Select Pull request target branch as the field
    • Choose matches regex as the operator
    • Input your target branch regex (e.g., ^release/v\d+\.\d+ for semantic versioned release branches, or ^main$ for only the main branch)
  • Save the webhook—now only PRs targeting branches matching your regex will trigger a build request to Bamboo

2. Secondary Filter: Bamboo Repository Trigger Branch Filter (Double Safety)

To add an extra layer of protection (in case the BitBucket webhook condition ever fails), you can also configure Bamboo to filter branches on its end:

  • Open your Bamboo plan and go to Configure Plan > Triggers
  • Find your BitBucket repository trigger and edit it
  • In the Branch filtering section, select Include branches matching this regular expression
  • Paste the same regex you used in BitBucket
  • Make sure the trigger is set to Trigger on pull request creation/update

This ensures that even if a stray trigger request makes it to Bamboo, the instance will automatically ignore it and not create a plan branch or start any builds.

Why This Beats Conditional Pipeline Tasks

  • No pipeline maintenance overhead: You don't have to add conditional logic to every stage or task—your pipeline stays clean and easy to manage
  • Zero build records for non-qualifying PRs: BitBucket won't show any build status (success/failure) for PRs that don't match, which is exactly what you want
  • More efficient: Reduces unnecessary network traffic and saves Bamboo resources by avoiding useless build attempts

Bonus: Clean Up Existing Unwanted Branches

If you already have plan branches from non-qualifying PRs, you can:

  • Go to your Bamboo plan's Branches tab and delete them manually
  • Or set up auto-cleanup: In your plan's Configure Plan > Branch Management, enable Auto remove inactive branches and set a threshold (e.g., remove branches inactive for 7 days)

内容的提问来源于stack exchange,提问作者psq

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.30 16:27:39