Reputation: 86757
I have a project /templates
where I want to add a common ci_settings.xml
that sets some defaults for maven
commands.
I then want to reuse this template in another project:
.gitlab_ci.yml
:
image: maven:3.8.4-eclipse-temurin-11
include:
project: 'all/templates'
ref: master
file:
- 'ci_settings.xml'
deploy:
stage: deploy
script: mvn deploy -s ci_settings.xml
Result:
Found errors in your .gitlab-ci.yml:
Included file `ci_settings.xml` does not have YAML extension!
How can I actually make use of this external file, if not via include
?
Upvotes: 1
Views: 2309
Reputation: 5146
You can use include
only with yml files. But you can clone the /templates
project in your pipeline via CI_JOB_TOKEN
and use it this way. As you don't need the commit history here you can set the depth to 1.
image: maven:3.8.4-eclipse-temurin-11
deploy:
stage: deploy
script:
- git clone --depth 1 https://gitlab-ci-token:${CI_JOB_TOKEN}@your_path_to_templates_project.git templates
- mvn deploy -s templates/ci_settings.xml
Upvotes: 2