Branch Limiting: separate filter for tags vs branches

Hello there!

In one of our pipelines, we want builds to be created on trunk and release/* branches, but also on any tag.

If we use “Settings” > “GitHub” > “Branch Limiting” to set it to trunk release/*, this will filter out branches that are not matching those two… but will also filter out tags too! The fact that the setting is called “Branch Limiting” (and the corresponding terraform attribute branch_configuration) is quite misleading—and actually led to a lot of time lost today trying to understand why our tags didn’t trigger a build on a new pipeline I just set up :sweat: , first thinking it was the webhook or that we forgot to enable provider_settings.build_tags = true in our terraform config.

Would be be possible to make the distinction between “Branch Limiting” (which would only apply to branches, not tags) and add a separate “Tag Limiting” field, so that we can have the limitation only on branches or only on tags, instead of a single field that applies to both (which imho makes little sense anyway, as tag names and branch names rarely follow the same naming convention anyway)?

PS: We don’t want to impose any restriction on tag naming so having a “Branch Limiting” filter set to something like trunk release v* wouldn’t work well for us. Besides, that would also mean that builds would be created on any branch whose name starts with v too, which is not what we want.

Hello Ohalligon,

Welcome to the Buildkite community! I noticed that you’ve set up branch filtering correctly, but the same filtering pattern is being applied to tags as well. This is normal because when you apply branch filtering, it checks the branch that the commit belongs to before starting the build.

To achieve your desired setup of triggering builds for all tags and specific branch patterns, you can utilize the “Filter builds using conditionals” feature under the “trigger builds after pushing code” option in your GitHub settings within the pipeline settings. This option, however, will filter builds based on a conditional expression. Only conditional expressions that evaluate to true will result in a build being created. For your scenario, the conditional expression should be something like build.tag != null || build.branch =~ /^release// where the build will check if there’s any tag, if yes, then it builds, or it’ll only build if the branch name follows the pattern of release/*.

When applying this filter condition, make sure to have the “Build tags” checkbox enabled. The build.tag != null conditional will only evaluate if this checkbox is checked.

Please let us know if you need anything else and we’ll be more than happy to assist further.