Always build library before application in Jenkins

2019-05-02 10:16发布

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?

4条回答
Evening l夕情丶
2楼-- · 2019-05-02 11:00

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.

查看更多
劳资没心,怎么记你
3楼-- · 2019-05-02 11:00

Under Advanced Options in the job A configuration, select Block build when upstream project is building. And make job A depend on job B.

查看更多
霸刀☆藐视天下
4楼-- · 2019-05-02 11:02

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.

查看更多
爱情/是我丢掉的垃圾
5楼-- · 2019-05-02 11:03

There is a Parameterized Trigger Plugin, which enables "Trigger/call builds on other projects" in "Add build step" menu.

https://stackoverflow.com/q/5701697/366299

查看更多
登录 后发表回答