HiveBrain v1.2.0
Get Started
← Back to all entries
patternpythonMinor

Parametrize gitlab ci pipeline

Submitted by: @import:stackexchange-devops··
0
Viewed 0 times
parametrizegitlabpipeline

Problem

There is the following simple pipeline:

buildtestdeploy

that 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_37test_37deploy_37

build_38test_38deploy_38

build_39test_39deploy_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 build

Code Snippets

build:
  image: python:${PY_VERSION}
  parallel:
    matrix:
      - PY_VERSION: ["3.7", "3.8", "3.9"]
  script: poetry build

Context

StackExchange DevOps Q#14703, answer score: 3

Revisions (0)

No revisions yet.