Effect of a default sections for included yaml file

Hi

If your top yaml file uses the include to include a number of yaml files from other directories, is this like an “ordinary C #include”?
That is, the runner first include all files into one large one and then parse/execute it?
Or do the gitlab runner treat each included a separately and walk over the includes in turn, that is, regardless of what it is in individual yaml files, one can not not affect others?

The concern is if one of the include files have a default: section.

A)
If several yaml files are include in one “top file”, can each included individually file define all the stages?

B)
If several yaml files are include in one “top file”, will they be executed in the order they are include?

C)
How does it work if one yaml file have a default: sections, will this section affect all other included files?

D)
Is there a tag that guarantee remove any effect from default parts?
Like

job1:
  clean_run:

That remove all effects pre setup of the environment like

default:
variables:

In any case, can a individual yaml file do the following in the job section to cancel any affect from a default section, that comes from either the top file or any other included yaml files ?

job1:
  before_script: []
  after_script: []
  script:
    - .....

GitLab first parses all the files and put them together in one huge file, and then it executes such file.

From the documentation:

The include files are:

  • Merged with those in the .gitlab-ci.yml file.
  • Always evaluated first and then merged with the content of the .gitlab-ci.yml file, regardless of the position of the include keyword.

If several yaml files are include in one “top file”, can each included individually file define all the stages?

Yes, it doesn’t give an error

If several yaml files are include in one “top file”, will they be executed in the order they are include?

No, the order doesn’t really matter, you should consider the final result

How does it work if one yaml file have a default: sections, will this section affect all other included files?

Yes, there is some documentation about this behavior: GitLab CI/CD include examples | GitLab

In any case, can a individual yaml file do the following in the job section to cancel any affect from a default section, that comes from either the top file or any other included yaml files ?

Yes, an empty array will override the default, the most specific key overrides the most generic one: GitLab CI/CD include examples | GitLab

Ahh, great, thanks a lot for your information

so

before_script: []
after_script: []

can be used to prevent the building environment get “dirty” from the global ones, but it wont get ride of

variables:

So there is nothing like

job1:
  clean_run:

That guarantee that a job do not get affected in any way?

No, indeed, given they are default, they are, well, defaulted everywhere. To override variables, you can use unset in a before_script: unset(1p) - Linux manual page