Hi James,

> I have two projects - A and B. B depends on A.
>
> A is built with a number (call it a build number). B needs to which number
> is in A at the time B builds.
>
> Any ideas how to achieve this without any human intervention?

For B to query A at *runtime* of B: embed your build numbers in the JAR
manifest.

With the buildnumber-maven-plugin, it's something like this:
https://github.com/scijava/pom-scijava/blob/69b3520e486b2a3d65636833efe230b00f3ea78f/pom.xml#L680
And this:
https://github.com/scijava/pom-scijava/blob/69b3520e486b2a3d65636833efe230b00f3ea78f/pom.xml#L567

Then you can extract the version information out the manifest using Java's
built-in API:
http://docs.oracle.com/javase/7/docs/api/java/util/jar/JarFile.html#getManifest()
http://docs.oracle.com/javase/7/docs/api/index.html?java/util/jar/Manifest.html

To query A at B's *build* time as you request -- i.e., for your Jenkins job
that builds B to query the version of A, to decide whether to even build --
you could use the Jenkins Groovy plugin with the "Poll with a Groovy
script" ScriptTrigger that checks whether the build number changed since
the last build, using the above approach...

But is there some reason it's not good enough to simply have B's build be a
downstream job of A's build?

Regards,
Curtis


On Fri, May 9, 2014 at 9:02 AM, James Green <james.mk.gr...@gmail.com>wrote:

> I have two projects - A and B. B depends on A.
>
> A is built with a number (call it a build number). B needs to which number
> is in A at the time B builds.
>
> Any ideas how to achieve this without any human intervention?
>
> FWIW the use case here is that A is software distributed by B (a WAR
> archive). A queries B for an updated build number, thus implementing
> "automatic updates". I'm trying to automate the setting of this number
> across the two projects but I've drawn a blank inside Jenkins for the
> moment.
>
> James
>

Reply via email to