How to use include:local to have a script template?

How to use include:local to have a script template?

I have some jobs that are identical except for some variables. So I would like to extract the identical part into a template file and use include:local.

Here how I did my template file /templates/.dataflow-template.yaml:

image: python:latest
before_script:
  - pip install virtualenv
  - virtualenv venv
  - source venv/bin/activate
  - pip install apache-beam[gcp]==2.23.0 $PYTHON_LIB
script:
  - python -m $DATAFLOW_MODULE --runner DataflowRunner

And in my .gitlab-ci.yml, I include this template like this:

dataflow:
  stage: DataFlow
  variables:
    DATAFLOW_MODULE: tiling
    PYTHON_LIB: Pillow==7.1.2
  include: '/templates/.dataflow-template.yaml'

But, I have this message :

root config contains unknown keys: dataflow

So:

  • is it possible to use template to define script?
  • if yes, could you help me? :slight_smile:

Thank you for your help