Successfully added
DevOps
by Patrik
Reusing CI Scripts with Git Submodules
Using Git submodules is a clean way to share CI scripts between projects. You create a separate repository for your shared CI folder and link it as a submodule inside each project.
Steps:
-
Move your shared CI files (scripts, configs, etc.) into a separate Git repo.
-
In each project, add the submodule:
git submodule add https://gitlab.com/your-group/ci-templates.git CI
- Commit the changes:
git add .gitmodules CI git commit -m "Add CI submodule"
- Update submodules when cloning:
git submodule update --init --recursive
Benefits:
- Keeps scripts version-controlled and consistent
- Easy to manage changes centrally
Use this when: You want full access to the CI folder and version control it tightly.
git
submodules
ci
reuse
gitlab
Referenced in:
Comments