We have a Java project that consists of four layers and a folder holding 
the main build scripts. These are all in their own git repository, hosted 
on BitBucket. We have a Jenkins server running on our network and the 
builds are triggered by BitBucket using a POST hook for more control:

http://{username}:{password}@{IP}:{port}/job/{project}/build?token={token}

(using the Jenkins hook in BitBucket would work fine as well)

The Jenkins job consists of a Multiple SCM (Jenkins plugin) task, which 
clones all five repositories and then executes the main Gradle script to 
build the subprojects and the main project in one go, resulting in a single 
jar.

Everything works fine, however now the build is triggered on every commit, 
so if you add new functionality that spans two layers, you will get two 
builds. This happens because you will first commit something to one layer's 
repository and then to the other. The first commit will break the build, 
the second one will restore it. Although this is expected behaviour, it 
would be very nice if we could have some mechanism, to only build once, 
after the second commit. Because that is really when the whole change is 
committed. We of course want to prevent people from becoming desensitised 
by too many mails about broken builds.

In searching for a solution I could not find anyone who seemed to have this 
particular problem. What would be the recommended way to try and tackle 
this? I can imagine three approaches:

   1. Not use multiple repo's, although the architect and lead dev really 
   want them to keep the layers separate.
   2. Somehow trigger the build manually after the second commit or prevent 
   it from being triggered after the first commit manually.
   3. Have BitBucket trigger a polling job in Jenkins, which waits a set 
   amount of time and then builds all of the changes in one go.

The latter sounds like the only reasonable solution, but at the cost of 
making all builds slower, because of the delay and also you would need to 
be pretty fast at committing. Who's out there who has a better solution? 
Are people actually using multi-repo projects or is it generally 
discouraged for reasons of build complexity? There seems to be very little 
documentation on this.

What are the best practices here according to your experience?

Duplicate of my question on stackoverflow: 
http://stackoverflow.com/questions/28299213/how-to-correctly-trigger-builds-from-bitbucket-in-a-multi-repository-project-on

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/8eac6a9d-0667-4d1f-b2c3-231f1fa6f90d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to