how to wget artifacts in nexus oss 3.1

6,590 views
Skip to first unread message

niristotle okram

unread,
Nov 7, 2016, 1:33:24 PM11/7/16
to Nexus Users
just upgraded to nexus3 . And caught clueless on the REST API to download artifacts from nexus. With 2.x this use to work http://stackoverflow.com/questions/23596257/how-to-download-artifacts-using-wget-from-sonatype-nexus  


Downloaded the nexus book 3.x and didn't find it here too 

Jeffry Hesse

unread,
Nov 7, 2016, 1:52:20 PM11/7/16
to niristotle okram, Nexus Users
Hi there,

At current time there is not a REST endpoint to do this. REST is coming in the future however, stay tuned!

Jeffry

On Mon, Nov 7, 2016 at 9:33 AM niristotle okram <nirish...@gmail.com> wrote:
just upgraded to nexus3 . And caught clueless on the REST API to download artifacts from nexus. With 2.x this use to work http://stackoverflow.com/questions/23596257/how-to-download-artifacts-using-wget-from-sonatype-nexus  


Downloaded the nexus book 3.x and didn't find it here too 

--
You received this message because you are subscribed to the Google Groups "Nexus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nexus-users...@glists.sonatype.com.
To post to this group, send email to nexus...@glists.sonatype.com.
To view this discussion on the web visit https://groups.google.com/a/glists.sonatype.com/d/msgid/nexus-users/f1e5ab0e-3737-41f8-a19c-56f9c639e521%40glists.sonatype.com.
For more options, visit https://groups.google.com/a/glists.sonatype.com/d/optout.

niristotle okram

unread,
Nov 7, 2016, 2:18:37 PM11/7/16
to Jeffry Hesse, Nexus Users
Thanks for letting me know... 
I have to downgrade now. 

On Mon, Nov 7, 2016 at 12:52 PM, Jeffry Hesse <jhe...@sonatype.com> wrote:
Hi there,

At current time there is not a REST endpoint to do this. REST is coming in the future however, stay tuned!

Jeffry
On Mon, Nov 7, 2016 at 9:33 AM niristotle okram <nirish...@gmail.com> wrote:
just upgraded to nexus3 . And caught clueless on the REST API to download artifacts from nexus. With 2.x this use to work http://stackoverflow.com/questions/23596257/how-to-download-artifacts-using-wget-from-sonatype-nexus  


Downloaded the nexus book 3.x and didn't find it here too 

--
You received this message because you are subscribed to the Google Groups "Nexus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nexus-users+unsubscribe@glists.sonatype.com.



--
Regards
nirish okram

Jeffry Hesse

unread,
Nov 7, 2016, 2:22:04 PM11/7/16
to niristotle okram, Nexus Users
Never like hearing that. There's a potential (if you want to work with me), to use our Provisioning API:


Of note, you would need to write a Groovy Script that handles your current use case. We don't have anything on hand at current time that accomplishes what you are asking for, but this is certainly a use case that people ask for. 

On Mon, Nov 7, 2016 at 10:18 AM niristotle okram <nirish...@gmail.com> wrote:
Thanks for letting me know... 
I have to downgrade now. 
On Mon, Nov 7, 2016 at 12:52 PM, Jeffry Hesse <jhe...@sonatype.com> wrote:
Hi there,

At current time there is not a REST endpoint to do this. REST is coming in the future however, stay tuned!

Jeffry
On Mon, Nov 7, 2016 at 9:33 AM niristotle okram <nirish...@gmail.com> wrote:
just upgraded to nexus3 . And caught clueless on the REST API to download artifacts from nexus. With 2.x this use to work http://stackoverflow.com/questions/23596257/how-to-download-artifacts-using-wget-from-sonatype-nexus  


Downloaded the nexus book 3.x and didn't find it here too 

--
You received this message because you are subscribed to the Google Groups "Nexus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nexus-users...@glists.sonatype.com.



--
Regards
nirish okram

niristotle okram

unread,
Nov 7, 2016, 2:29:58 PM11/7/16
to Jeffry Hesse, Nexus Users
agggggg, i just rm -rf 'ed the 2 dir's for nexus. it was a test instance. downgrade was not the right word. 
I will look into the book and see what i can leverage. 

Thanks 

On Mon, Nov 7, 2016 at 1:21 PM, Jeffry Hesse <jhe...@sonatype.com> wrote:
Never like hearing that. There's a potential (if you want to work with me), to use our Provisioning API:


Of note, you would need to write a Groovy Script that handles your current use case. We don't have anything on hand at current time that accomplishes what you are asking for, but this is certainly a use case that people ask for. 
On Mon, Nov 7, 2016 at 10:18 AM niristotle okram <nirish...@gmail.com> wrote:
Thanks for letting me know... 
I have to downgrade now. 
On Mon, Nov 7, 2016 at 12:52 PM, Jeffry Hesse <jhe...@sonatype.com> wrote:
Hi there,

At current time there is not a REST endpoint to do this. REST is coming in the future however, stay tuned!

Jeffry
On Mon, Nov 7, 2016 at 9:33 AM niristotle okram <nirish...@gmail.com> wrote:
just upgraded to nexus3 . And caught clueless on the REST API to download artifacts from nexus. With 2.x this use to work http://stackoverflow.com/questions/23596257/how-to-download-artifacts-using-wget-from-sonatype-nexus  


Downloaded the nexus book 3.x and didn't find it here too 

--
You received this message because you are subscribed to the Google Groups "Nexus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nexus-users+unsubscribe@glists.sonatype.com.



--
Regards
nirish okram



--
Regards
nirish okram

Jeffry Hesse

unread,
Nov 7, 2016, 2:30:54 PM11/7/16
to niristotle okram, Nexus Users
Cool, just reach out to me if you have any questions, I'll do my best to help you out.

On Mon, Nov 7, 2016 at 10:29 AM niristotle okram <nirish...@gmail.com> wrote:
agggggg, i just rm -rf 'ed the 2 dir's for nexus. it was a test instance. downgrade was not the right word. 
I will look into the book and see what i can leverage. 

Thanks 
On Mon, Nov 7, 2016 at 1:21 PM, Jeffry Hesse <jhe...@sonatype.com> wrote:
Never like hearing that. There's a potential (if you want to work with me), to use our Provisioning API:


Of note, you would need to write a Groovy Script that handles your current use case. We don't have anything on hand at current time that accomplishes what you are asking for, but this is certainly a use case that people ask for. 
On Mon, Nov 7, 2016 at 10:18 AM niristotle okram <nirish...@gmail.com> wrote:
Thanks for letting me know... 
I have to downgrade now. 
On Mon, Nov 7, 2016 at 12:52 PM, Jeffry Hesse <jhe...@sonatype.com> wrote:
Hi there,

At current time there is not a REST endpoint to do this. REST is coming in the future however, stay tuned!

Jeffry
On Mon, Nov 7, 2016 at 9:33 AM niristotle okram <nirish...@gmail.com> wrote:
just upgraded to nexus3 . And caught clueless on the REST API to download artifacts from nexus. With 2.x this use to work http://stackoverflow.com/questions/23596257/how-to-download-artifacts-using-wget-from-sonatype-nexus  


Downloaded the nexus book 3.x and didn't find it here too 

--
You received this message because you are subscribed to the Google Groups "Nexus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nexus-users...@glists.sonatype.com.



--
Regards
nirish okram



--
Regards
nirish okram

--
You received this message because you are subscribed to the Google Groups "Nexus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nexus-users...@glists.sonatype.com.

To post to this group, send email to nexus...@glists.sonatype.com.

Manfred Moser

unread,
Nov 7, 2016, 2:38:09 PM11/7/16
to nirish...@gmail.com, jhe...@sonatype.com, nexus...@glists.sonatype.com

While there is no REST API as such you can easily download any artifact from v3. Just instead of using GAV parameters against the API.. you use the same parameters to assemble the URL of the artifact and then just download it with wget or curl. 

For a specific artifact you can also just use the web user interface of the server to locate it and in the assets use direct link provided. It shows the full url

E.g. it could be something like

wget http://localhost:8081/repository/maven-public/junit/junit/4.12/junit.jar

 

That works just fine.

Jeffry Hesse

unread,
Nov 7, 2016, 2:46:11 PM11/7/16
to Manfred Moser, nirish...@gmail.com, nexus...@glists.sonatype.com
Very true. Went flying right over my head, if the use case is just this simple you can assemble the URL Manfred pointed out. The part that threw me, and I'm not sure if it matters to you is the snapshot, release filter, as well as the v=latest from the linked Support article in the Stack Overflow link (https://support.sonatype.com/hc/en-us/articles/213465488-How-can-I-retrieve-a-snapshot-if-I-don-t-know-the-exact-filename-). You can work around the release/snapshot by making a request to the specific repository, latest is what we don't have yet. 

Harpreet Nain

unread,
Nov 7, 2016, 5:28:40 PM11/7/16
to Nexus Users, man...@simpligility.com, nirish...@gmail.com
I have been looking for this as well. Can you please elaborate how would we fetch the snapshots ? I was unable to download it using the snapshot version. Only if I use the timestamp in the version can I get the snapshots. Maybe I am missing something here.

Please advise.

Regards
Harpreet

Manfred Moser

unread,
Nov 8, 2016, 1:56:49 PM11/8/16
to Harpreet Nain, Nexus Users, Manfred Moser, niristotle okram
You have to download the maven-metadata.xml file, parse and interpret
it and then assemble the filename with the parameters from the file.

Manfred
> https://groups.google.com/a/glists.sonatype.com/d/msgid/nexus-users/46d3db68-b5ad-49fc-9ea0-7a3e0a71cc4b%40glists.sonatype.com.

Robert Turnbull

unread,
Nov 9, 2016, 5:40:36 AM11/9/16
to niristotle okram, Nexus Users
If you are comfortable with parsing XML, you can generate wget URL's from maven metadata.

https://NEXUS/repository/maven-public/GROUP/ID/ARTIFACT-ID/maven-metadata.xml to get a list of versions including latest and latest release

With this you can generate URL for full releases
 

With this you can generate URL for snapshots

On 7 November 2016 at 22:33, niristotle okram <nirish...@gmail.com> wrote:
just upgraded to nexus3 . And caught clueless on the REST API to download artifacts from nexus. With 2.x this use to work http://stackoverflow.com/questions/23596257/how-to-download-artifacts-using-wget-from-sonatype-nexus  


Downloaded the nexus book 3.x and didn't find it here too 

--
You received this message because you are subscribed to the Google Groups "Nexus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nexus-users+unsubscribe@glists.sonatype.com.



--
Robert Turnbull
Tel: +230 5 7012833

Мартынов Илья

unread,
Jan 10, 2017, 5:57:03 AM1/10/17
to Nexus Users, nirish...@gmail.com
Is it possible to delete artifacts this way?


среда, 9 ноября 2016 г., 13:40:36 UTC+3 пользователь Robert Turnbull написал:
If you are comfortable with parsing XML, you can generate wget URL's from maven metadata.

https://NEXUS/repository/maven-public/GROUP/ID/ARTIFACT-ID/maven-metadata.xml to get a list of versions including latest and latest release

With this you can generate URL for full releases
 

With this you can generate URL for snapshots
On 7 November 2016 at 22:33, niristotle okram <nirish...@gmail.com> wrote:
just upgraded to nexus3 . And caught clueless on the REST API to download artifacts from nexus. With 2.x this use to work http://stackoverflow.com/questions/23596257/how-to-download-artifacts-using-wget-from-sonatype-nexus  


Downloaded the nexus book 3.x and didn't find it here too 

--
You received this message because you are subscribed to the Google Groups "Nexus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nexus-users...@glists.sonatype.com.

Peter Lynch

unread,
Jan 10, 2017, 6:17:37 AM1/10/17
to Мартынов Илья, Nexus Users, niristotle okram
On Tue, Jan 10, 2017 at 6:57 AM, Мартынов Илья <imart...@gmail.com> wrote:
Is it possible to delete artifacts this way?



If you know the direct content URL for a Maven artifact inside a hosted or proxy repository, you can send an HTTP DELETE request to delete that path from the repository.
 
To unsubscribe from this group and stop receiving emails from it, send an email to nexus-users+unsubscribe@glists.sonatype.com.

To post to this group, send email to nexus...@glists.sonatype.com.

Dave H

unread,
Jan 16, 2017, 3:55:08 PM1/16/17
to Nexus Users, nirish...@gmail.com
I got a 404 when attempting to download maven-metadata.xml from a snapshot repository....any ideas on that?


On Wednesday, November 9, 2016 at 5:40:36 AM UTC-5, Robert Turnbull wrote:
If you are comfortable with parsing XML, you can generate wget URL's from maven metadata.

https://NEXUS/repository/maven-public/GROUP/ID/ARTIFACT-ID/maven-metadata.xml to get a list of versions including latest and latest release

With this you can generate URL for full releases
 

With this you can generate URL for snapshots
On 7 November 2016 at 22:33, niristotle okram <nirish...@gmail.com> wrote:
just upgraded to nexus3 . And caught clueless on the REST API to download artifacts from nexus. With 2.x this use to work http://stackoverflow.com/questions/23596257/how-to-download-artifacts-using-wget-from-sonatype-nexus  


Downloaded the nexus book 3.x and didn't find it here too 

--
You received this message because you are subscribed to the Google Groups "Nexus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nexus-users...@glists.sonatype.com.

Peter Lynch

unread,
Jan 16, 2017, 5:21:44 PM1/16/17
to Dave H, Nexus Users, niristotle okram
On Mon, Jan 16, 2017 at 4:55 PM, Dave H <david....@gmail.com> wrote:
I got a 404 when attempting to download maven-metadata.xml from a snapshot repository....any ideas on that?

To unsubscribe from this group and stop receiving emails from it, send an email to nexus-users+unsubscribe@glists.sonatype.com.

To post to this group, send email to nexus...@glists.sonatype.com.

Dave H

unread,
Jan 17, 2017, 4:16:47 PM1/17/17
to Nexus Users, david....@gmail.com, nirish...@gmail.com
Turns out my mistake was not realizing that the elements of the artifact groupID need to be separated by slashes and not dots.

George Kopf

unread,
Feb 12, 2017, 2:07:22 AM2/12/17
to Nexus Users, nirish...@gmail.com
I used your idea and wrote this bare bones bash script to parse the metadata.  


On Wednesday, 9 November 2016 05:40:36 UTC-5, Robert Turnbull wrote:
If you are comfortable with parsing XML, you can generate wget URL's from maven metadata.

https://NEXUS/repository/maven-public/GROUP/ID/ARTIFACT-ID/maven-metadata.xml to get a list of versions including latest and latest release

With this you can generate URL for full releases
 

With this you can generate URL for snapshots
On 7 November 2016 at 22:33, niristotle okram <nirish...@gmail.com> wrote:
just upgraded to nexus3 . And caught clueless on the REST API to download artifacts from nexus. With 2.x this use to work http://stackoverflow.com/questions/23596257/how-to-download-artifacts-using-wget-from-sonatype-nexus  


Downloaded the nexus book 3.x and didn't find it here too 

--
You received this message because you are subscribed to the Google Groups "Nexus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nexus-users...@glists.sonatype.com.
getLatestArtifact.sh

George Kopf

unread,
Feb 18, 2017, 1:53:22 AM2/18/17
to Nexus Users
I rewrote my bash script as a chef recipe.   Somebody please tell me if there is an easier way.

# Written by George Kopf
# Cookbook:: applyDemo
# Recipe:: default
#
# Copyright:: 2017, The Authors, All Rights Reserved.

remote_file '/home/tomcat/baseMetadata.xml' do
  mode '0755'
  action :create
end

ruby_block 'parse the baseMetadata.xml file' do
block do
  baseMetadata = File.readlines("/home/tomcat/baseMetadata.xml")
  baseMetadataLine = baseMetadata.grep(/<version>/)
  node.default['baseVersion'] = baseMetadataLine.first[/version>(.*?)<\/version/, 1]
  end
  action :run
end

remote_file '/home/tomcat/elementMetadata.xml' do
  mode '0755'
  action :create
end

ruby_block 'parse the elementMetadata.xml file' do
  block do
    elementMetadata = File.readlines("/home/tomcat/elementMetadata.xml")
    elementMetadataLines = elementMetadata.grep(/<value>/)
    node.default['elementVersion'] = elementMetadataLines.first[/<value>(.*?)<\/value>/,1]
  end
end

remote_file '/home/tomcat/demo.war.zip' do
  mode '0755'
  action :create
end

ruby_block 'Deploy and clean up' do
  block do
    FileUtils.rm_rf '/usr/share/tomcat/webapps/demo*'
    File.rename '/home/tomcat/demo.war.zip', '/usr/share/tomcat/webapps/demo.war.zip'
    File.rename '/usr/share/tomcat/webapps/demo.war.zip', '/usr/share/tomcat/webapps/demo.war'
    File.delete '/home/tomcat/baseMetadata.xml'
    File.delete '/home/tomcat/elementMetadata.xml'
    end
end
Message has been deleted

Isaac H.

unread,
Jun 23, 2017, 11:26:01 AM6/23/17
to Nexus Users
Here's my bash script to get the RELEASE

if [ "${VERSION}" == "RELEASE" ]; then
  VERSION=`cat mavenmeta.xml | grep release | sed 's/release//g ; s/[\<\>\/ ]//g'`
fi


WARNAME="dashboard-${VERSION}.war"

curl ${URL} -o ${WARNAME} -k

John Kramer

unread,
Dec 5, 2017, 11:38:15 PM12/5/17
to Nexus Users, nirish...@gmail.com
Jeffry,

Can we get an update as to where this is?

It's pretty crucial functionality. Thanks!


John
Reply all
Reply to author
Forward
0 new messages