In our build and deploy infrastructure, we have a Jenkins job that builds our multi-module Maven projects, and recently has been deploying the resulting artifacts (including an omnibus tarball) to Nexus. Then another job (sometimes triggered by a successful build job) runs the deploy, which pulls the required artifact from Nexus, based on the POM that the build job ran (the build job archives the POM so that the tarball can be retrieved by using the dependency:copy goal). For releases, this works fine and we can even deploy an earlier version if a rollback scenario is required. However, this breaks down for SNAPSHOT builds, because the POM does not contain any version identifier beyond that the artifact is a -SNAPSHOT
.
The build output does contain information that could be grepped after the build is complete, so that we could use that as the version. Those familiar with Maven will recognize the following Maven output snippet:
[INFO] Uploading: http://nexus.eng.company.com/nexus/content/repositories/snapshots/com/company/application/application-dist/4.19.3-SNAPSHOT/application-dist-4.19.3-20160819.223606-7-eng.tar.gz
[INFO] Uploaded: http://nexus.eng.company.com/nexus/content/repositories/snapshots/com/company/application/application-dist/4.19.3-SNAPSHOT/application-dist-4.19.3-20160819.223606-7-eng.tar.gz (109687 KB at 413.1 KB/sec)
But is there a better way? The situation we are specifically trying to allow is for developers to deploy earlier builds (usually to deploy feature branch builds) but that currently isn't possible unless I find a way to grab that datestamped version identifier.