Stefan_EOX
Stefan_EOX

Reputation: 1529

Read .gitlab-ci.yml variables from a file

I have been searching for ways to read a file with environment variables in GitLab CI/CD. Specifically they should be used in the services entry of a job.

variables:
#  POSTGRES_USER: testuser
#  POSTGRES_PASSWORD: testpw
#  POSTGRES_DB: testdb

test:
  image: python:3
  services:
    - name: postgis/postgis

I want to read the variables from a file stored in the same repository.

Upvotes: 11

Views: 20983

Answers (1)

Stefan_EOX
Stefan_EOX

Reputation: 1529

This can be achieved by the include keyword:

include: /test/postgis.yml

with /test/postgis.yml having these contents:

variables:
  POSTGRES_USER: testuser
  POSTGRES_PASSWORD: testpw
  POSTGRES_DB: testdb

Upvotes: 9

Related Questions