Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run GitLab CI for a subdirectory in the same project

I have three subprojects (Angular and Node.js) in the same GitLab project. Now I want to create the gitlab-ci.yml file for building and deploying one of this subprojects. Can I create three different gitlab-ci.yml files and run them inside subdirectories? Is it possible? Or should I push those into three different projects?

Enter image description here

like image 733
Tharindu Lakshan Avatar asked Jan 25 '26 23:01

Tharindu Lakshan


1 Answers

My personal preference is to keep projects small. So I usually create one GitLab project per, e.g., module, library, program, design, etc.

But if you really wanted to, you could easily either:

  • Create a single .gitlab-ci.yml that goes something like:

    my_job:
      stage: test
      script:
        - |
           cd "$CI_PROJECT_DIR/folder1"
           < do stuff >
           cd "$CI_PROJECT_DIR/folder2"
           < do stuff>
           ...
    
  • Create multiple gitlab-ci configurations inside the folders and include them in the root .gitlab-ci.yml file

    include:
      - 'folder1/pipeline.yml'
      - 'folder2/pipeline.yml'
    

Note that when using the second option, you will still have to cd folderX since pipelines always start in the repository's root directory, no matter from where they are imported.

like image 162
uupascal Avatar answered Jan 27 '26 17:01

uupascal



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!