buildkite / feedback

Got feedback? Please let us know!
https://buildkite.com
25 stars 24 forks source link

Allow Github Pull Request builds to be filtered based on target branches #482

Closed tduffield closed 5 years ago

tduffield commented 5 years ago

For pipelines that are triggered by GitHub Pull Request events, I need the ability to filter builds by the name of the target branch.

For example, let's say that I have two long-lived release branches in a single repo: master and legacy. Pull Requests are actively being opened against both branches, but they have entirely different pipeline requirements and are developed by separate teams.

I want to create two pipelines, one for each release branch. I want to be able to send post commit statuses from the correct pipeline to the appropriate PR.

moensch commented 5 years ago

Could this be done using dynamic pipelines?

if [[ $BUILDKITE_PULL_REQUEST_BASE_BRANCH = "legacy" ]]; then
  buildkite-agent pipeline upload .buildkite/pipeline_legacy.yml
else
  buildkite-agent pipeline upload .buildkite/pipeline_master.yml
fi
tduffield commented 5 years ago

Not in my case. Each branch is treated as an independent project, and thus gets its own pipeline. Each pipeline exists in isolation.

I'm aware of all the workarounds, but that's not what I /want/. I'm asking for very specific native behavior to be present so that I do not require a workaround.

My ask is that if I can filter based on the name of the head branch in the PR, I'm also be able to filter based on the name of the target branch.

kerrick-lyft commented 5 years ago

We also need this feature, and the suggestion to use BUILDKITE_PULL_REQUEST_BASE_BRANCH also doesn't work for us.

The issue with BUILDKITE_PULL_REQUEST_BASE_BRANCH is that we have only one server running specialized tests for PRs against a specific target branch (we don't need to run these tests for other target branches). We can't run this pipeline for all PRs, because even if we use BUILDKITE_PULL_REQUEST_BASE_BRANCH to no-op the tests, it will still overwhelm the server and create a backlog, because there's a fixed overhead each time we run the pipeline on the server.

Please implement this feature :)

kerrick-lyft commented 5 years ago

I've been corrected by my coworkers, we think that moenschs's suggestion will work for us. Will post an update once we implement it and see if things work.

moensch commented 5 years ago

You would still enter the appropriate branch in the branch field for what you’re building. You just enter the extra three env vars for Buildkite to recognize it as a PR build rather than just a branch build. We needed this because we have toiling that relies on the pull request number env var to be set if branch is not master.

keithpitt commented 5 years ago

Just wanted to let everyone know we’ve got a solution for this behind a feature flag.

If someone stumbles across this and wants access, send us an email hello@buildkite.com and we’ll flip it on for you :)