Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trigger a TeamCity build on changes in a git submodule

How to setup TeamCity trigger to start build on changes in git submodule?

Currently you have to update a submodule commit pointer to trigger a build in the main repository, so that TC will register a change in the main repository.

Update

The problem is the submodule should be always tracking a branch master. AFAIK this cannot be achieved through git itself. I just would like for the build to overcome git limitation in that matter.

like image 896
Janusz Skonieczny Avatar asked May 23 '14 09:05

Janusz Skonieczny


2 Answers

This is not a neat solution but is achieves a goal to build a project with the tip of the submodule, and not needing to update submodule by hand. (A hook would probably do to)

Create a separate build configuration on with the submodule as the main repo, and setup a command line build step to clone a maste-repo, pull/update submodule and push the updated submodule pointer back to the master-repo.

rm -r master-repo
git clone [email protected]:xxx/master-repo.git
cd master-repo
git status
git submodule update --init 
git config -f .gitmodules submodule.submodule-repo.branch master
cd submodule-repo
git pull origin master
git status
cd ..
git add submodule-repo
git commit -m "sub module update"
git push origin master

I'm new to git so this probably can be optimized.

like image 105
Janusz Skonieczny Avatar answered Nov 13 '22 09:11

Janusz Skonieczny


It is not possible to do that as TeamCity (and git) cannot know that there is an update. Submodule entry in a repo just points to a commit.

What would be an update to it? There can be multiple branches and commits from this commit. Only you can decide where the submodule is to be updated to.

like image 1
manojlds Avatar answered Nov 13 '22 09:11

manojlds