Thanks Juanito.
In the meantime, I got something working by using build meta-data and dynamic pipeline.
On the first pipeline, I have one step that use the conditional to set metadata:
- label: ":triangular_flag_on_post:"
command: buildkite-agent meta-data set "my-flag" "true"
if: "build.pull_request.labels includes \"my label\""
I’ve then modified my trigger step to dynamically upload itself to the pipeline and set the env
variables based on the meta-data set in that previous step.
- command: ".buildkite/trigger-tests.sh"
label: ":hammer: Test"
.buildkite/trigger-tests.sh
:
#!/bin/bash
set -euo pipefail
# Set up a variable to hold the meta-data from previous steps
MY_FLAG="$(buildkite-agent meta-data get "my-flag" --default "")"
# Create a pipeline with the trigger step
PIPELINE="steps:
- trigger: \"web-tests\"
label: \":hammer: Test\"
async: true
build:
message: ${BUILDKITE_MESSAGE}
commit: ${BUILDKITE_COMMIT}
branch: ${BUILDKITE_BRANCH}
env:
BUILDKITE_PULL_REQUEST: ${BUILDKITE_PULL_REQUEST}
BUILDKITE_PULL_REQUEST_BASE_BRANCH: ${BUILDKITE_PULL_REQUEST_BASE_BRANCH}
BUILDKITE_PULL_REQUEST_REPO: ${BUILDKITE_PULL_REQUEST_REPO}
MY_FLAG: ${MY_FLAG}
"
# Upload the new pipeline and add it to the current build
echo "$PIPELINE" | buildkite-agent pipeline upload