Matrix jobs execute the same script with different inputs
Inputs are specified using environment variables
The matrix
keyword under parallel
defines variables sets
Matrix variables can be used for…
Cross-compile Go for multiple architectures
Extend template to support GOOS
and GOARCH
:
.build-go:
#...
parallel:
matrix:
- GOOS: linux
GOARCH: amd64
- GOOS: linux
GOARCH: arm64
script:
- go build -o hello-${GOOS}-${GOARCH} . \
-ldflags "-X main.Version=${CI_COMMIT_REF_NAME} -X 'main.Author=${AUTHOR}'"
Update the test job:
test:
#...
script:
- ./hello-linux-amd64
Check pipeline
See new .gitlab-ci.yml
:
git checkout origin/160_gitlab_ci/150_matrix_jobs -- '*'