-
-
Save bobhenkel/4acf0c85ede0363dba6752926f260ef3 to your computer and use it in GitHub Desktop.
Ensuring Buildkite pipeline steps run on the same agent, using a dynamic pipeline generator script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Outputs a pipeline that targets agents that have the same 'name' meta-data | |
# value as the step that does the pipeline upload. This means that all the | |
# steps will run on the same agent machine, assuming that the 'name' meta-data | |
# value is unique to each agent. | |
# | |
# Each agent needs to be configured with meta-data like so: | |
# | |
# meta-data="name=<unique-name>" | |
# | |
# To use, save this file as .buildkite/pipeline.sh, 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 | |
# | |
name=$(buildkite-agent meta-data get name) | |
cat << EOF | |
steps: | |
- command: step-1.sh | |
name: "First step" | |
agents: | |
name: "$name" | |
- command: step-2.sh | |
name: "Second step" | |
agents: | |
name: "$name" | |
- command: step-3.sh | |
name: "Third step" | |
agents: | |
name: "$name" | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment