Geniy
Geniy

Reputation: 405

jenkins submodule build on git commit

We have some project with gradle submodules in one git repository.

|project
|-submodule1
|-submodule1-api
|-submodule2
|-submodule2-api
|-submodule3
|-submodule3-api

On commit to this git repository Jenkins starts jobs (compile, test, SCA) (we use git web hooks. see https://stackoverflow.com/a/12794930/1623597). We have jobs for every submodule (submodule1, submodule2, etc).

the problem is that Jenkins starts all ~10 jobs.

  1. Is it possible to trigger job only if we have changes in some specific class? (like project/submodule2/src/main/java/com/test/Hello.java)

  2. Is it possible to have some variable in git hook? that will trigger only specific build in jenkins?

  3. Does jenkins have plugin that will trigger build if we have changes for specific directory?

Upvotes: 2

Views: 1621

Answers (1)

Vamsi Ravi
Vamsi Ravi

Reputation: 1236

Jenkins Git plug-in lets you define this in job's configuration. In Source Code Management / Git / Additional Behaviours choose an option for this called Polling ignore commits in certain paths.

If set, and Jenkins is set to poll for changes, Jenkins will pay attention to included and/or excluded files and/or folders when determining if a build needs to be triggered. Using this behaviour will preclude the faster git ls-remote polling mechanism, forcing polling to require a workspace thus sometimes triggering unwanted builds, as if you had selected the Force polling using workspace extension as well.

Then your will be able to configure the includes or excludes regions from which you do or don't want to trigger builds by using the regular expressions. So that you can restrict polling policy.

For further information please refer to build-in Help (?).

Upvotes: 1

Related Questions