To sum up on top of user1717259's answer (using Nexus 3.37.3-02).
Bash one-liner using curl
and sed
:
BASE_URL="https://your-nexus-server.com"
# All of the following query parameters are optional, and
# defaults to <empty> if not specified otherwise, and
# wildcards can be used as well.
params="repository=<the-repository-id>"
params+="&maven.groupId=<the-group-id>"
params+="&maven.artifactId=<the-atifact-id>"
params+="&maven.baseVersion=<the-version>" # can be <empty>, `1.2.3`, `1.2.3-SNAPSHOT`, or `1.2.*`, etc.
params+="&maven.extendsion=<the-extension>"
params+="&maven.classifier=<the-classifier>"
params+="&sort=<the-sort-field>" # can be <empty>, `group`, `name`, `version`, 'repository'
params+="&direction=<the-sort-direction>" # can be `asc`, and `desc` (the default)
params+="&prerelease=<empty, true, or false>" # default (<empty>) to search releases and prereleases
DOWNLOAD_URL=$(curl -s -k -i "$BASE_URL/service/rest/v1/search/assets/download?$params" | sed -n -E 's/^Location: ([^\r\n]+).*$/\1/p')
Version comparison examples:
1.2.3
< 1.3.0-SNAPSHOT
< 1.3.0-CD2-SNAPSHOT
< 1.3.0-CD12-SNAPSHOT
< 1.3.0-RC1
< 1.3.0
< 1.4.0-SNAPSHOT