curl -L -u admin:admin123 -X GET \ "http://localhost:8081/service/rest/v1/search/assets/download?sort=version&repository=maven-releases&maven.groupId=com.example&maven.artifactId=my-app&maven.extension=jar" \ --output latest-app.jar Use code with caution.
Use the following curl command, replacing the bracketed placeholders with your repository details:
: This special version string tells Nexus 2 to find the most recent non-snapshot release. Advanced: Extracting the Download URL Manually
# 1. Get the download URL from the JSON response DOWNLOAD_URL=$(curl -s "http://[nexus-url]/service/rest/v1/search/assets?repository=[repo]&maven.groupId=[group]" | jq -r '.items[0].downloadUrl') # 2. Download the file using the extracted URL curl -L -O "$DOWNLOAD_URL" Use code with caution.
: Use -s in your curl commands within scripts to suppress the progress meter and error messages, making logs cleaner.
If you need to perform additional logic (like checking metadata) before downloading, you can use the Search API to get a JSON response and then parse the downloadUrl . This often requires a tool like jq to extract the link.
To grab the latest my-app JAR from a repository named maven-releases :
curl -L -u admin:admin123 -X GET \ "http://localhost:8081/service/rest/v1/search/assets/download?sort=version&repository=maven-releases&maven.groupId=com.example&maven.artifactId=my-app&maven.extension=jar" \ --output latest-app.jar Use code with caution.
Use the following curl command, replacing the bracketed placeholders with your repository details:
: This special version string tells Nexus 2 to find the most recent non-snapshot release. Advanced: Extracting the Download URL Manually
# 1. Get the download URL from the JSON response DOWNLOAD_URL=$(curl -s "http://[nexus-url]/service/rest/v1/search/assets?repository=[repo]&maven.groupId=[group]" | jq -r '.items[0].downloadUrl') # 2. Download the file using the extracted URL curl -L -O "$DOWNLOAD_URL" Use code with caution.
: Use -s in your curl commands within scripts to suppress the progress meter and error messages, making logs cleaner.
If you need to perform additional logic (like checking metadata) before downloading, you can use the Search API to get a JSON response and then parse the downloadUrl . This often requires a tool like jq to extract the link.
To grab the latest my-app JAR from a repository named maven-releases :
© Copyright: 2026 Guangzhou Dtech Electronics Technology Co.,Ltd. All Rights Reserved.