run gitlab-ci for sub directory in same project

Viewed 3732

I have three sub-projects (Angular & Node) in the same GitLab project. Now I want to create the gitlab-ci.yml file for build and deploy one of this sub-project. can I create three different gitlab-ci.yml & run them inside sub-directories? is it possible? or should I push those into three different projects?

enter image description here

1 Answers

My personal preference is, to keep projects small. So i usually create one GitLab Project per e.g. Module, Library, Programm, 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 multipe gitlab-ci configurations inside the folders and include them in the root .gitlab-ci.yml
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 repos root-dir, no matter from where they are imported.

Related