Skip to content

Instantly share code, notes, and snippets.

@toolmantim
Created July 30, 2016 07:14
Show Gist options
  • Select an option

  • Save toolmantim/e9d2cd2dacf2919b0090a0baa50b7a50 to your computer and use it in GitHub Desktop.

Select an option

Save toolmantim/e9d2cd2dacf2919b0090a0baa50b7a50 to your computer and use it in GitHub Desktop.
Demonstration of how to do environment variable substitution with buildkite-agent 2.x (in 3.x env var support is built-in)
#!/bin/bash
set -euo pipefail
# Demonstration of how to do environment variable substitution with
# buildkite-agent 2.x (in 3.x env var support is built-in)
#
# To use, save this file as .buildkite/pipeline.bash, chmod +x, and
# then set your first pipeline step to run this and pipe it into
# pipeline upload:
#
# .buildkite/pipeline.sh | buildkite-agent pipeline upload
#
cat << EOF
steps:
- trigger: "another-pipeline"
build:
message: "Deploying build $BUILDKITE_BUILD_NUMBER"
commit: "$BUILDKITE_COMMIT"
branch: "$BUILDKITE_BRANCH"
env:
SOME_ENV: "$SOME_ENV"
EOF
@toolmantim
Copy link
Author

toolmantim commented May 8, 2017

Alternatively you could use the following pipeline upload step:

( echo "cat <<EOF" ; cat .buildkite/pipeline.yml ; echo EOF ) | sh | buildkite-agent pipeline upload

@eastokes
Copy link

@toolmantim .buildkite/pipeline.sh | buildkite-agent pipeline upload works great for me (adding the cat EOF stuff), but when I try ( echo "cat <<EOF" ; cat .buildkite/pipeline.yml ; echo EOF ) | sh | buildkite-agent pipeline upload on a regular pipeline file, it goes into an infinite loop and duplicates all the steps in the pipeline continuously

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment