Using the Nexus rest API to get latest artifact version for given groupid/artifactId

后端 未结 6 1195
走了就别回头了
走了就别回头了 2020-11-27 14:53

I am trying to use the nexus REST api to get the latest version of a maven artifact. I am able to browse to the specific version I am looking for using http://repo.loc

6条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-27 15:30

    After trying the REST service with the LATEST version, and discovering it doesn't always work (See @Stanislav response) I ended up creating this one-liner Linux command for parsing the metadata.xml file:

    wget -O - -o /dev/null https://repo1.maven.org/maven2/org/brutusin/wava/maven-metadata.xml | grep -Po '(?<=)([0-9\.]+(-SNAPSHOT)?)' | sort --version-sort -r | head -n 1
    

    Just change the to the appropiate url, and it should work for you.

    Cheers

提交回复
热议问题