I have a submodule A that is not a standalone application. It requires the main application for it to work. I would like to create a CI build for A so that whenever a commit
This can be done without git hooks. In this example we have 3 repos:
When cloned with sub-modules it looks like:
parent\
child-a\*
child-b\*
In Jenkins create a freestyle project called dummy-child-a
.
Source Code Management
setup the Repository URL
for child-a
Build Triggers
you choose Poll SCM
and set your desired interval Build
click Add build step
Execute Windows batch command
or Execute shell
depending on your OSecho hello
(this is the dummy part)Repeat these steps for child-b
In Jenkins create a freestyle project called parent
. This is where we will actually do the building
Source Code Management
setup the Repository URL
for parent
add
under Additional Behaviours
and choose Advanced sub-modules behaviours
Recursively update submodules
Update tracking submodules to tip of branch
Use credentials from default remote of parent repository
Build Triggers
check Build after other projects are built
Projects to watch
field, fill all projects to watch with comma separation: dummy-child-a, dummy-child-b
parent
doesn't have source code that will change, You don't need to Poll SCM
on this Jenkins jobTrigger even if the build fails
And you're done. Any changes to either child-a or child-b will trigger a rebuild of parent. This method assumes that the number of submodules in parent changes infrequently. If you were to add another submodule you would need to make another dummy
project, and then update the projects to watch
of the parent
Jenkins build.