Incremental build in Jenkins

2019-03-20 18:41发布

问题:

I am using Jenkins 1.462 and maven version is 3.0.4. At Jenkins I enabled check-box "Incremental build - only build changed modules"

I want to figure out 2 questions:

  1. Whether incremental build is sufficient? Here How do I trigger a Jenkins build of a single module in a multi-module Maven build from Subversion? for example is stated that it doesn't work at 100% Here http://www.slideshare.net/andrewbayer/7-habits-of-highly-effective-jenkins-users at page 19 is stated that incremental builds are complementary to full builds, not replacements.

  2. Whether Incremental build - only build changed modules is actually works as expected? What I mean by this? If I have modules A, B, X, C, D. X uses A and B, C use X, D use C and I make change in X module. Than I want to recompile modules X (itslef), C (that use X directly) and D (that is in transitive closure; D use C, that use C).

Note: this is the only change that I did in order to enable incremental build.

回答1:

As stated by Maven documentation incremental builds are not very reliable at least until 3.0.4:

Currently (3.0.4) Apache Maven doesn't support incremental builds very well.

https://cwiki.apache.org/confluence/display/MAVEN/Incremental+Builds (first line)

Instead, I would strongly suggest using any of these two approaches for speeding up your build:

  • Using parallel builds. In my experience in large projects this works great and can greatly reduce the build time with minimum (if any) risk. Just execute something like mvn -T 1.5C clean install https://cwiki.apache.org/confluence/display/MAVEN/Parallel+builds+in+Maven+3

  • If your modules are independent you can rather move them to different projects and glue them together by using maven dependencies.