0

I have an automated deployment pipeline setup via GitLab's integrated CI:

(1) I have a CentOS server with a GitLab runner (using the shell executor)

(2) I have a repository that contains a .gitlab-ci.yml file and a .gitsubmodules file specifying two repositories

(3) My .gitsubmodules file specifies the master branch of each submodule, and looks like this:

[submodule "api"]
    path = api
    url = ../api.git
    branch = master
[submodule "client"]
    path = client
    url = ../client.git
    branch = master

I am working directly in the submodules directories (./client and ./api).

I would like the parent directory (i.e. the 'deployment' repository that contains the two submodules) to really only reflect changes to the master branches of the submodules. However I find this is not happening (if this helps... I changed the .submodules file to have branch = master AFTER working with the repo for a while.

I find when I push the deployment project to GitLab that the submodules setup includes the most recent commit of ANY branch, and not the master branch as I want.

I have this in the .gitlab-ci.yml file to specify how submodules are setup:

GIT_SUBMODULE_STRATEGY: recursive

What am I doing wrong? i.e. How can I specify in the .gitlab-ci.yml file or otherwise that I ONLY want to use the master branch of the submodules?

This answer: How to specify the submodule branch in gitlab-ci? doesn't work for me.

Zach Smith
  • 8,458
  • 13
  • 59
  • 133

1 Answers1

0

It seems that I can tell the top level repo to look at the latest commit on a submodule's particular branch via specifying --remote:

git submodule update --remote --recursive

That is according to this answer: https://stackoverflow.com/a/18797720/3114742

However I feel that this is a little hacky and I'd like a better way if there is one

Zach Smith
  • 8,458
  • 13
  • 59
  • 133