I have a similar question about the matrix feature. I have a pipeline template that can build multiple images of a "base" docker image, where each image differs in the version of the tool. For example, I want to build custom "base" .NET images for .NET 3.1, 5.0, and 6.1.
Previously I was declaring a variable:
VERSIONS_TO_BUILD: "3.1 5.0 6.0"
and then looping through that list (eg: foreach ver in VERSION_TO_BUILD, run docker build).
I am also scanning the resulting containers. So, multiple jobs would have the same matrix list.
I just discovered this matrix functionality. I realize I can setup my job as such:
build:
parallel:
matrix:
- VERSION: 3.1
- VERSION: 5.0
- VERSION: 6.0
# repeat for scan job
As mentioned, I am using a template so the same pipeline can be used for .NET, Node, Java, Maven, etc. What I am hoping to do is to include the template, then define the versions I'm using for that repo, then re-use it.
include:
- base_image_pipeline.yml
variables:
VERSIONS:
- "3.1"
- "5.0"
- "6.0"
build:
parallel:
matrix:
- $VERSIONS
scan:
parallel:
matrix:
- $VERSIONS
I have a feeling the !reference keyword might be the best option, but would like other inputs.
Thanks!