Tharindu Lakshan
Tharindu Lakshan

Reputation: 6136

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

Upvotes: 13

Views: 21564

Answers (1)

phoehnel
phoehnel

Reputation: 839

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.

Upvotes: 21

Related Questions