We’re excited to announce the Build Matrix, a new way of creating multiple jobs from a single, multi-variant step definition. For example, rather than creating three separate pipelines for macOS, Linux and Windows builds, you could use the matrix to create all of these variants from within a single step.
Build Matrix expands a single step into multiple steps by replacing the {{matrix}}
variable in the label and command attributes of a command step with each value provided in the matrix array. You can interpolate the matrix values into command steps (including step labels) and into environment variables.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
steps: - name: ":{{matrix.os}}: {{matrix.arch}}" command: ".buildkite/steps/build-binary.sh {{matrix.os}} {{matrix.arch}}" matrix: setup: os: - darwin - freebsd - linux - openbsd - windows arch: - "386" - amd64 - arm64
For customers dealing with complex, repetitive pipelines, this update will allow them to avoid boilerplate and duplication, and reduce the time spent managing multiple separate pipelines and builds. As an example, see this recent PR against our own agent repository, which reduced a 402-line pipeline down to 160 lines 📉.
Once you’re up to speed with the basic, there are also a range of power user features available ⚡️:
- For more complex builds you can add multiple dimensions to
matrix.setup
instead of the matrix array. - You can add combos by using the adjustments key to define all of the elements in the matrix.
- You can also group matrix jobs to make it easier to make sense of what’s happening in your builds
The Build Matrix is available today to every Buildkite customer — for more information check out the documentation 📚.