Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 933
Stefan_EOX Avatar asked Apr 07 '26 22:04

Stefan_EOX


1 Answers

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
like image 112
Stefan_EOX Avatar answered Apr 10 '26 09:04

Stefan_EOX