Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins Partial Build / Modular Build on Commit Hook

Tools:
Jenkins ver. 1.470
Maven 2
Subversion

Environment

Assume my build has a number of projects A-D. The dependency graph exists as shown. That is to say: B depends on classes in A, C depends on classes in B, D depends on classes in A. We create the jenkins builds such that they call the builds dependent upon them as a post-build action.

A
|--> B --> C
|--> D

Each night, we trigger a full build in Jenkins (A builds, triggers B (triggers C), triggers D). This is done easily enough by telling A to build nightly, and the rest cascades.

Problem

However, on a commit we want to build the projects that were committed to once.

  • Situation 1: We poll the repository (or use commit hooks, it makes no difference) and find that there was a commit to B, then B will build and C will build. Success!

  • Situation 2: We poll the repository and find that B and C were committed to in one commit, then Jenkins will try to build B (triggering a build of C), and build C (a second build). Failure. See what happens? C was built twice, taking up precious build time. Keep the build fast!

Does anyone know a way to only trigger the highest project in each committed build pipeline?

I suppose one solution would be a complex SVN hook that determines the highest project in each pipeline...

  • Situation 3: Commit to B C and D in one commit. SVN hook finds C depends on B. The hook calls project-specific links to start builds for B and D.

Pitfalls: Very complex SVN commit hook. Have to upkeep the pipeline in the SVN hook.

I feel like this is a problem others have run into. Is there a Jenkins plugin that helps with this?

like image 313
Thundertoe Avatar asked Jun 19 '12 20:06

Thundertoe


1 Answers

It would be an idea to say jenkins to wait with the build until a build that c depends on is finished. The is an flag within the job configuration in order to do that. But you have to do this for each job. Btw ... there is also another flag that requires jenkins to wait with the build until a dependend job is finished.

like image 56
Robert Franz Avatar answered Sep 21 '22 12:09

Robert Franz