mr.nothing
mr.nothing

Reputation: 5399

maven get nexus latest snapshot build number

When we're deploying artifact to the nexus, we have them deployed with the following name artifact-11-20120320.181629-555.jar.

So my question is can we get this 555 from the nexus before deploying artifact using some REST API query? I need this information to include it into the rpm that I produce during maven build.

Thanks in advance!

Upvotes: 3

Views: 1351

Answers (2)

mr.nothing
mr.nothing

Reputation: 5399

Ok, I've found out how to do this by myself. Here is the bash script which retrieves this info:

version=`curl --silent 'http://REPO_URL/service/local/artifact/maven/resolve?r=REPO_NAME&g=GROUP_ID&a=ARTEFACT_ID&v=VERSION&e=PACKAGING' | sed -n 's/.*<snapshotBuildNumber>\(.*\)<\/snapshotBuildNumber>.*/\1/p'`
echo $version

Upvotes: 2

Guillaume Darmont
Guillaume Darmont

Reputation: 5018

I don't know if you can get 555 before uploading the artifact, but as a workaround, you can try to read the maven-metadata.xml after the artifact is deployed.

This file is located in the same folder than your artifacts.

Upvotes: 1

Related Questions