Reputation: 4401
I have a base file .gitlab-ci.yml:
include:
- project: 'my-group/my-project'
file: 'test1.yml'
test1.yml:
stages:
-test_stage1
test_stage1:
stage: test_stage1
script: //some script
it works fine, test_stage1 runs successfully.
Now if I want to include other file as well:
include:
- project: 'my-group/my-project'
file: 'test1.yml'
- project: 'my-group/my-project'
file: 'test2.yml'
test2.yml:
stages:
-test_stage2
test_stage2:
stage: test_stage2
script: //some script
I get the following error:
This GitLab CI configuration is invalid: test_stage job: stage parameter should be test_stage2
So I have to add explicitly the stages:
include:
- project: 'my-group/my-project'
file: 'test1.yml'
- project: 'my-group/my-project'
file: 'test2.yml'
stages:
-test_stage1
-test_stage2
And it works.
Why is that?
Am I able to somehow just include multiple files and go through all of their stages without declaring them?
Upvotes: 6
Views: 5197
Reputation: 1668
You need to define your stages so that GitLab CI knows the sequence of stages.
See the documentation.
Am I able to somehow just include multiple files and go through all of their stages without declaring them?
Not if you want to have multiple stages. You need to tell GitLab CI which stage comes first, second etc., so that all the jobs for each stage can be run before going on to the next stage. That gives us a pipeline.
The default stage is test
, by the way. If you don't provide the stage
attribute for a job, it'll be assigned to the test
stage.
Upvotes: 7