We're having two builds A and B, where A is an application which depends on library B. Both are Qt projects. Jenkins polls the SCM every 15 minutes. Sometimes it happens that I commit A and B but the timer of A ends before the timer of B. So the Application gets build with an old library, which causes the build to fail. Now I'm looking for a way to tell Jenkins that B has to be built before the build of A starts. However, it's only possible to build something after a successful build.
Is there a simple solution or have we just messed up our build process?
There are some open bugs in Jenkins related to project references and messed build order. See this bug (or this one). See comments for possible workarounds.
Under Advanced Options in the job A configuration, select Block build when upstream project is building. And make job A depend on job B.
If you switch to Apache Ivy for your dependency management, you can have A triggered, whenever you publish a new version of B (using the Jenkins Ivy Plugin), assuming that A is depending on the
latest.integration
(or similar) version of B.This won't stop A from building against an old version of B, but at least it will automatically build again when B is finished.
Also, consider settings up post receive hooks to trigger Jenkins, and adding a quiet period to A. Then when you push changes to A and B, both A and B will be triggered straight away, but A will wait a little while before building. When A's quiet period expires, the
Block build when upstream project is building
option can be used to force it to wait till B has completed.Finally, when you've been using Ivy for a while, you'll probably come to the same conclusion as many others: you don't want A depending on
latest.integration
of B, but a specific version instead. It allows deterministic builds and simplifies the CI job setup (only build A when it's code (which includes the version of B it depends on) changes), but you need to come to that realisation yourself, in your own time.BTW even though Ivy is very Java focused, I've uses it very successfully on non-java projects; don't be put off.
https://stackoverflow.com/q/5701697/366299