patternpythonMinor
Parametrize gitlab ci pipeline
Viewed 0 times
parametrizegitlabpipeline
Problem
There is the following simple pipeline:
that uses specified
How can I scale (parametrize) it for
Simplest solution that comes to mind is to create 3 different pipelines with hardcoded
I know this is a very bad solution.
What is the right way?
build → test → deploythat uses specified
python version for all stages, for example 3.8.How can I scale (parametrize) it for
python with versions: 3.7, 3.8 and 3.9?Simplest solution that comes to mind is to create 3 different pipelines with hardcoded
python versions:build_37 → test_37 → deploy_37build_38 → test_38 → deploy_38build_39 → test_39 → deploy_39.I know this is a very bad solution.
What is the right way?
Solution
I would suggest to use the parallel matrix feature of GitLab CI (see also here). As Bruce Becker suggested utilizing
tox is also a valid option and exactly designed for your use case.build:
image: python:${PY_VERSION}
parallel:
matrix:
- PY_VERSION: ["3.7", "3.8", "3.9"]
script: poetry buildCode Snippets
build:
image: python:${PY_VERSION}
parallel:
matrix:
- PY_VERSION: ["3.7", "3.8", "3.9"]
script: poetry buildContext
StackExchange DevOps Q#14703, answer score: 3
Revisions (0)
No revisions yet.