1

If I deploy an artifact to a Maven repository with version number 1.0.0-SNAPSHOT, it will get an internal version number of the form 1.0.0-21321323-2 (timestamp and number). How can I find out this version number?

4
  • The given number is created by the appropriate repository manager which you usually don't need. Or you need it ? For what purpose?
    – khmarbaise
    Feb 4, 2016 at 15:51
  • We use explicit versions (for different reasons) as dependencies in some cases. I need to record and store them during the deployment for future reference. Feb 4, 2016 at 16:04
  • To be more explicit: Our "pre-maven-system" allows to depend on "The third version in 1.0.0-SNAPSHOT". For legacy and other reasons, we need to keep this behaviour alive in some way. Feb 4, 2016 at 16:07
  • I assume you are using some kind of CI solution like Jenkins? If yes you can access this information after complete build via REST API from jenkins (you need to use the deploy linke plugin) and you can use the Jenkins Java API to extract the information from jenkins...for example in Java...
    – khmarbaise
    Feb 4, 2016 at 16:23

1 Answer 1

2

When deploying an artifact to Artifactory you get a JSON response which includes the URI of the deployed artifact. You can use that to get the timestamp version. For example:

{
  "repo" : "libs-snapshot-local",
  "path" : "/org/jfrog/buildinfo/build-info-extractor-maven3/2.5.4-SNAPSHOT/build-info-extractor-maven3-2.5.4-20160205.203000-1.jar",
  "created" : "2016-02-05T22:30:00.624+02:00",
  "createdBy" : "admin",
  "downloadUri" : "http://localhost:8081/artifactory/libs-snapshot-local/org/jfrog/buildinfo/build-info-extractor-maven3/2.5.4-SNAPSHOT/build-info-extractor-maven3-2.5.4-20160205.203000-1.jar",
  "mimeType" : "application/java-archive",
  "size" : "67966",
  "checksums" : {
    "sha1" : "f608440d5aadc64a5ef50320a385aeae49abd58a",
    "md5" : "a844a8ab8226ff25854127480f3cfeac"
  },
  "originalChecksums" : {
  },
  "uri" : "http://localhost:8081/artifactory/libs-snapshot-local/org/jfrog/buildinfo/build-info-extractor-maven3/2.5.4-SNAPSHOT/build-info-extractor-maven3-2.5.4-20160205.203000-1.jar"
}

Another option is using the latest version search REST API which allows searching for the latest artifact version by groupId and artifactId. For example:

$ curl -uadmin:password "http://localhost:8081/artifactory/api/search/latestVersion?g=org.jfrog.buildinfo&a=build-info-extractor-maven3&v=2.5.4-SNAPSHOT&repos=libs-snapshot-local"

2.5.4-20160205.203000-1
2
  • What kind of deploying is necessary for this? I probably cannot access this information if I use maven deploy:deploy-file . Feb 5, 2016 at 20:49
  • Any deployment will get this response (PUT request to the deployment URL). However Maven will not show the response body. I suggest you will use the latest version search instead Feb 5, 2016 at 20:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.