Can I use VARIABLE in INCLUDE statement block in gitlab-ci.yml?

Example:

I would like to use environment variable from external repo (`$CI_PROJECT_PATH) and use it in my .gitlab-ci.yml file in INCLUDE block

include:

  • project: ‘$VARIABLE_example’
    ref: master
    file: ‘var1.yml’

even local does not work:

variables:
  PR1: 'path/infrastructure/infra/test_trigger'

stages:
  - test
  - test2


include:
  - project: $PR
    ref: master
    file: 'var1.yml'

but the syntax is incorrect: "Project $PR not found "

1 Like

Also just stumbled over this, but the docs are clear on this: Use CI/CD configuration from other files | GitLab

You cannot use variables defined in jobs, or in a global variables section which defines the default variables for all jobs. Includes are evaluated before jobs, so these variables cannot be used with include.