部署SNAPSHOT版本 - 获取(带时间戳)版本号

时间:2016-02-04 15:28:32

标签: maven nexus artifactory snapshot

如果我将工件部署到版本号为1.0.0-SNAPSHOT的Maven存储库,它将获得1.0.0-21321323-2(时间戳和数字)形式的内部版本号。我怎样才能找到这个版本号?

1 个答案:

答案 0 :(得分:2)

将工件部署到Artifactory时,您将获得一个JSON响应,其中包含已部署工件的URI。您可以使用它来获取时间戳版本。例如:

{
  "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"
}

另一种选择是使用latest version search REST API,它允许通过groupId和artifactId搜索最新的工件版本。 例如:

$ 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