Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gitlab 'include local' from same project but different directory

So lets say I have a project structure like:

project-fancy-name
    -> jobs
        -> build
            - build-maven.yml
        -> defaults
            - maven-defaults.yml

And in the build-maven.yml I want to include the defaults-maven.yml file.

I have tried the below combinations but all seem to give me this error or similar:Local file defaults/maven-defaults.yml does not exist!

include:
  - local: defaults/maven-defaults.yml


include:
  - local: /defaults/maven-defaults.yml


include:
  - local: ./defaults/maven-defaults.yml


include:
  - local: ../defaults/maven-defaults.yml

I was under the impression that using ../ may have gone back a directory but doesn't seem to be the case.

So what would the correct syntax be for including the local file maven-defaults.yml in the build-maven.yml file?

I have read the Gitlab Include reference material but it doesn't seem to give any examples that would work here.

like image 559
Popeye Avatar asked Aug 30 '26 07:08

Popeye


1 Answers

include: paths are relative to the project root, not relative to the file location. So just include the full path, relative to the project root:

include:
  - local: jobs/defaults/maven-defaults.yml
like image 132
sytech Avatar answered Sep 02 '26 17:09

sytech



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!