Reputation: 576
I'm working on project A, and A is depending on a fast-developing project B(its master branch).
Therefore, B is a submodule of A, everytime I build A, B is also re-built. Besides, everytime B has a new commit, I need to build B, then re-built A.(Luckily, the projects are small enough, so the compiling time isn't important).
Now, here's the point. I want to trigger a new build in Travis CI or other continuous integration services, when there is a new commit in project A or B.
I just tried Github & Travis CI. A commit in project B would not trigger a build in project A. Is there a simple way to run such a continuous integration?
Upvotes: 12
Views: 6280
Reputation: 61
I have used gitlab-ci to trigger a parent pipeline when a submodule is updated. Please check here
Upvotes: 1
Reputation: 576
Based on @VonC 's question, I solved this problem. Ref https://developer.github.com/webhooks/configuring/
trigger.rb
in project Monitorrequire 'sinatra'
post '/payload' do
system("git submodule update --remote")
system("git add .")
system("git commit -m Record_new_change")
system("git push")
puts "Finished handling"
end
./ngrok http 4567
. You may got a link like http://7e9ea9dc.ngrok.io
ruby trigger.rb
http://7e9ea9dc.ngrok.io/payload
for project A and B'In this way, the development for A and B is untouched, and the new builds can be triggered automatically.
Upvotes: 3
Reputation: 1323135
A commit in project B would not trigger a build in project A
That is expected, considering B has no idea A exists.
You would need to record the new state of B (new gitlink, special entry in the index) of project A by doing:
cd /path/to/projectA
git submodule update --remote
git add .
git commit -m "Record new B SHA1 gitlink"
git push
git submodule update --remote
will update submodule B to the latest commit of the branch recorded in A .gitmodules
file for B.
See "git submodule tracking latest" and "Git submodules: Specify a branch/tag"
Then a new Travis build would be triggered for A.
If you want to automate the sequence described above, you would need a webhook (GitHub) (or BitBucket) for projectB, and a local listener which, on a push event on repo B, would trigger the commands mentioned before in a local repo of project A.
Upvotes: 8