<p>No, you can't have multiple gitlab-ci files per repository.
You can see more information in the following links:</p>
<ul>
<li><a href="https://gitlab.com/gitlab-org/gitlab-foss/issues/18157" rel="nofollow noreferrer">https://gitlab.com/gitlab-org/gitlab-foss/issues/18157</a></li>
<li><a href="https://gitlab.com/gitlab-org/gitlab-foss/issues/28592" rel="nofollow noreferrer">https://gitlab.com/gitlab-org/gitlab-foss/issues/28592</a></li>
</ul>
<p>Now, there are some work in progress about this, but it's not available yet.</p>
<p>For example, you can <a href="https://gitlab.com/gitlab-org/gitlab-foss/issues/56214" rel="nofollow noreferrer">see here</a> that they are working on pipeline which can include other (complete) pipelines.</p>
<p>The <code>include</code> keyword is more about reducing the size of your main gitlab-ci file.</p>

CC BY-SA 4.0
2019-01-14T13:54:39.533Z
2023-03-03T11:53:08.767Z
2023-03-03T11:53:08.767Z
Aykut Açikel
<p>You are not able to create multiple <code>.gitlab-ci.yml</code> but you can manage to have what you want.</p>
<p>You currently have multiple software in the same repository with the same CI/CD Pipeline or jobs for your softwares.</p>
<p>You can use <code>include</code> in order to include local files from your repository, so you would get</p>
<pre class="lang-yaml prettyprint-override"><code>include:
  - local: 'my_folder/.gitlab-ci.yml'
</code></pre>
<p>You can reach the generic way you want by using <a href="https://docs.gitlab.com/ee/ci/variables/" rel="noreferrer">Gitlab Variables</a> and <a href="https://docs.gitlab.com/ee/ci/yaml/#extends" rel="noreferrer">extends</a>.</p>
<p>Basically, you would end up with something like the following:</p>
<pre><code>## my_folder/build.yml
# the `.` (dot) before build means that we don't want it run alone, we must
# extends to run this part
.build:
  variables:
    SOFTWARE_ROOT: &quot;&quot;
  script:
    - build ${SOFTWARE_ROOT}

## .gitlab-ci.yml
include:
  - local: 'my_folder/build.yml'

my_first_build:
  extends: .build
  variables:
   SOFTWARE_ROOT: &quot;first_software/&quot;

my_second_build:
  extends: .build
  variables:
    SOFTWARE_ROOT: &quot;second_software/&quot;

</code></pre>
<p>You can also put everything in the same file.</p>
<p>This way you only declare your build job once for all.</p>

CC BY-SA 4.0
2021-04-21T14:38:53.153Z
2021-04-21T14:38:53.153Z
Alexandre Burgoni
<p>I think „child/parent“ pipelines are what you are looking for: <a href="https://docs.gitlab.com/ee/ci/pipelines/pipeline_architectures.html#child--parent-pipelines" rel="nofollow noreferrer">https://docs.gitlab.com/ee/ci/pipelines/pipeline_architectures.html#child--parent-pipelines</a></p>

CC BY-SA 4.0
2022-06-16T16:15:43.683Z
As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer).
Community
CC BY-SA 4.0
2022-06-16T14:49:13.177Z
2022-06-16T14:49:13.177Z
Aydin K.
<p>I have a single repo handling integration tests for 4 different software projects. As those projects share common resources, I'd like to create a <strong>generic file</strong> in which all those common features are set properly for preparing the CI/CD job.<br>
The project organization looks like the following:</p>

<pre><code>project_root:
  &gt; folder_1
  &gt; folder_2
  &gt; folder_3
  &gt; folder_4
</code></pre>

<p>From <a href="https://docs.gitlab.com/ee/ci/yaml/#include" rel="noreferrer">GitLab's documentation</a> on the <code>include</code> keyword, I understand that it is possible to include a file that would handle the common features of all those projects so I don't have to write those command lines in the 4 differents <code>gitlab-ci.yml</code>. So I thought I could do the following:</p>

<pre><code>project_root:
 common-features-handler.yml
  &gt; folder_1
   gitlab-ci.yml
  &gt; folder_2
   gitlab-ci.yml
  &gt; folder_3
   gitlab-ci.yml
  &gt; folder_4
   gitlab-ci.yml
</code></pre>

<p>The thing is, the documentation is unclear on whether it is possible to have multiple <code>gitlab-ci.yml</code> files in the same repo, regardless of them being in separate folders. It just says that this file should be "placed at the root of [the] repository", so I guess this, in itself, excludes the possibility of having several <code>gitlab-ci.yml</code> files in the same repo. I tried including the <code>common-features-handler.yml</code> file in the <code>gitlab-ci.yml</code> from folder_1 but the job didn't even launched. My guess is that, as it was not at the root of the project, it simply wasn't seen by the CI pipeline. This makes me think that it's not possible for one repo to handle several gitlab-ci files, but I couldn't find anything about it in the doc or online to confirm or infirm this hypothesis.</p>

<p>So is it possible to have multiple gitlab-ci files in a single repo in one way or another? If not, is there a way for avoiding writing the same setup command lines four times?</p>

CC BY-SA 4.0
2018-12-10T15:24:29.217Z
In your project settings you can define where the .gitlab-ci.yml is, the main idea is to have one file per project, you may have a repo with multiple files to maintain them and have them include per project. (it's a bit terse for an answer, if someone want to extend from this, feel free)
Tensibai
<continuous-integration><gitlab><gitlab-ci-runner><yaml>
Is it possible to have multiple gitlab-ci files in a single repo?
avazula
# Is it possible to have multiple gitlab-ci files in a single repo?

(Asked by: username_0 on 2018-12-10)

I have a single repo handling integration tests for 4 different software projects. As those projects share common resources, I'd like to create a generic file in which all those common features are set properly for preparing the CI/CD job.
The project organization looks like the following:
project_root:
  > folder_1
  > folder_2
  > folder_3
  > folder_4

From GitLab's documentation on the include keyword, I understand that it is possible to include a file that would handle the common features of all those projects so I don't have to write those command lines in the 4 differents gitlab-ci.yml. So I thought I could do the following:
project_root:
 common-features-handler.yml
  > folder_1
   gitlab-ci.yml
  > folder_2
   gitlab-ci.yml
  > folder_3
   gitlab-ci.yml
  > folder_4
   gitlab-ci.yml

The thing is, the documentation is unclear on whether it is possible to have multiple gitlab-ci.yml files in the same repo, regardless of them being in separate folders. It just says that this file should be "placed at the root of [the] repository", so I guess this, in itself, excludes the possibility of having several gitlab-ci.yml files in the same repo. I tried including the common-features-handler.yml file in the gitlab-ci.yml from folder_1 but the job didn't even launched. My guess is that, as it was not at the root of the project, it simply wasn't seen by the CI pipeline. This makes me think that it's not possible for one repo to handle several gitlab-ci files, but I couldn't find anything about it in the doc or online to confirm or infirm this hypothesis.
So is it possible to have multiple gitlab-ci files in a single repo in one way or another? If not, is there a way for avoiding writing the same setup command lines four times?

**Tags:** continuous-integration, gitlab, gitlab-ci-runner, yaml

> **Comments:**
> **username_1**: In your project settings you can define where the .gitlab-ci.yml is, the main idea is to have one file per project, you may have a repo with multiple files to maintain them and have them include per project. (it's a bit terse for an answer, if someone want to extend from this, feel free)  

---

## 3 answers

### Answer by username_2 on 2019-01-14. Score: 14 | Accepted answer

No, you can't have multiple gitlab-ci files per repository.
You can see more information in the following links:

* <https://gitlab.com/gitlab-org/gitlab-foss/issues/18157>
* <https://gitlab.com/gitlab-org/gitlab-foss/issues/28592>

Now, there are some work in progress about this, but it's not available yet.

For example, you can [see here](https://gitlab.com/gitlab-org/gitlab-foss/issues/56214) that they are working on pipeline which can include other (complete) pipelines.

The `include` keyword is more about reducing the size of your main gitlab-ci file.


---

### Answer by username_3 on 2021-04-21. Score: 7

You are not able to create multiple .gitlab-ci.yml but you can manage to have what you want.
You currently have multiple software in the same repository with the same CI/CD Pipeline or jobs for your softwares.
You can use include in order to include local files from your repository, so you would get
include:
  - local: 'my_folder/.gitlab-ci.yml'

You can reach the generic way you want by using Gitlab Variables and extends.
Basically, you would end up with something like the following:
## my_folder/build.yml
# the `.` (dot) before build means that we don't want it run alone, we must
# extends to run this part
.build:
  variables:
    SOFTWARE_ROOT: ""
  script:
    - build ${SOFTWARE_ROOT}

## .gitlab-ci.yml
include:
  - local: 'my_folder/build.yml'

my_first_build:
  extends: .build
  variables:
   SOFTWARE_ROOT: "first_software/"

my_second_build:
  extends: .build
  variables:
    SOFTWARE_ROOT: "second_software/"


You can also put everything in the same file.
This way you only declare your build job once for all.


---

### Answer by username_4 on 2022-06-16. Score: 1

I think „child/parent“ pipelines are what you are looking for: <https://docs.gitlab.com/ee/ci/pipelines/pipeline_architectures.html#child--parent-pipelines>

> **Comments:**
> **username_5**: As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer).  

---

