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:

  1. Move your shared CI files (scripts, configs, etc.) into a separate Git repo.

  2. In each project, add the submodule:

    git submodule add https://gitlab.com/your-group/ci-templates.git CI
  3. Commit the changes:
    git add .gitmodules CI
    git commit -m "Add CI submodule"
  4. 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

Comments