8

Is there anyway I can create a two module projects in gradle, and trigger a build for each module by itself?

Root project 'Example' 
    Jenkinsfile
\--- Project ':SubProject'
    Jenkinsfile

I want that jenkins will trigger a build only in the module that has been changed.


for example :

If my SubProject changed, then only SubProject will execute it's own Jenkinsfile.

I looked up for this option for a very long time...

As you can see in the other questions, there is no any easy way to achieve that.

Is there any Jenkins pipeline or plugin that can deal with that?

Daniel Taub
  • 5,133
  • 7
  • 42
  • 72
  • If you want to trigger them after pushing code to the "subprojects" and you have just one repo have a look to git submodules https://git-scm.com/docs/git-submodule – dmarin Feb 07 '18 at 10:30

2 Answers2

3
  • It is relatively easy to only invoke the gradle tasks from a given subproject:
    • To build Example: ./gradlew :build
    • To build SubProject: ./gradlew :SubProject:build
    • Gradle will then only run the task graph these invocation define.
  • It should be relatively easy to setup two different jobs in Jenkins, based on distinct Jenkinsfile, and each could have the custom invocation defined above.

However, the triggering of one project only will most likely be the tricky thing as they most likely live in the same source control location.

Maybe the easy fix is also to have them decoupled, using svn:externals or Git submodules.

Louis Jacomet
  • 13,661
  • 2
  • 34
  • 43
0

Use excludedRegions to exclude folders/files that would trigger a build.

https://jenkins.io/doc/pipeline/steps/workflow-scm-step/

I'm unsure about the support of JenkinsFile...

Hoof
  • 1,738
  • 2
  • 17
  • 39