Run GitLab CI for a subdirectory in the same project
Asked Answered
S

1

13

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

Serviceman answered 11/1, 2022 at 17:37 Comment(0)
E
19

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.

Earflap answered 11/1, 2022 at 21:41 Comment(1)
Great touch with include feature!Symptomatology

© 2022 - 2024 — McMap. All rights reserved.