I have a single Git repository with several independent applications, developed in several languages (a.k.a monorepo).
In this repository, can I use multiple to be continuous templates to build in parallel all my projects ?
Sure you can.
Some build templates also support parallel matrix jobs, allowing you to handle multiple projects using the same template.
Suppose a GitLab project is made of the following:
app/
: a frontend application, developed in Angularusers-srv/
: a 1st backend service, developed in Node, packaged as a Docker imageorders-srv/
: a 2nd backend service, developed in Node, packaged as a Docker imagetools/
: some tooling, developed in PythonYour .gitlab-ci.yml
file should look like the following:
# included templates
include:
# Angular template
- project: "to-be-continuous/angular"
ref: "1.2.0"
file: "templates/gitlab-ci-angular.yml"
# Node.js template
- project: "to-be-continuous/node"
ref: "1.2.0"
file: "templates/gitlab-ci-node.yml"
# Python template
- project: "to-be-continuous/python"
ref: "1.2.0"
file: "templates/gitlab-ci-python.yml"
# Docker template
- project: "to-be-continuous/docker"
ref: "1.2.0"
file: "templates/gitlab-ci-docker.yml"
# variables
variables:
# path of the Angular project
NG_WORKSPACE_DIR: "app"
# path of the Python project
PYTHON_PROJECT_DIR: "tools"
# parallel matrix jobs for Node template
.node-base:
parallel:
matrix:
# path of the "users-srv" Node project
- NODE_PROJECT_DIR: "users-srv"
# path of the "orders-srv" Node project
- NODE_PROJECT_DIR: "orders-srv"
# parallel matrix jobs for Docker template
.docker-base:
parallel:
matrix:
# Docker config for project "users-srv"
- DOCKER_FILE: "users-srv/Dockerfile"
DOCKER_SNAPSHOT_IMAGE: "$CI_REGISTRY/$CI_PROJECT_PATH/users-srv/snapshot:$CI_COMMIT_REF_SLUG"
DOCKER_RELEASE_IMAGE: "$CI_REGISTRY/$CI_PROJECT_PATH/users-srv:$CI_COMMIT_REF_NAME"
# Docker config for project "orders-srv"
- DOCKER_FILE: "orders-srv/Dockerfile"
DOCKER_SNAPSHOT_IMAGE: "$CI_REGISTRY/$CI_PROJECT_PATH/orders-srv/snapshot:$CI_COMMIT_REF_SLUG"
DOCKER_RELEASE_IMAGE: "$CI_REGISTRY/$CI_PROJECT_PATH/orders-srv:$CI_COMMIT_REF_NAME"
# your pipeline stages
stages:
- build
- test
- package-build
- package-test
- deploy
- acceptance
- publish
- production