Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upload artifacts to Nexus, without Maven

Tags:

nexus

I have a non-Java project that produces a versioned build artifact, and I want to upload this to a Nexus repository. Because the project isn't Java, it doesn't use Maven for builds. And I'd rather not introduce Maven/POM files just to get files into Nexus.

The links on blogs to the Nexus REST API all end up at a sign-in wall, with no "create user" link that I can see.

So, what's the best (or any reasonable) way to upload build artifacts to a Nexus repository without Maven? "bash + curl" would be great, or even a Python script.

like image 522
Adam Vandenberg Avatar asked Oct 27 '10 02:10

Adam Vandenberg


People also ask

How do I manually upload an artifact to Nexus?

First load of the Nexus repository manager admin console. The first thing you need to do is provide the Maven group, artifact, version and packaging attributes for the deployment artifact you are about to upload. After doing so, use the Select Artifacts to Upload button to browse to the JAR file of interest.

How we can upload artifacts into Nexus repository manager?

Go to "http://localhost:8081/nexus" Login as user: "admin" password: "admin123" Click on "Browse Repositories," and you'll see a list of repositories. You will want to right click on the "3rd Party" repository and choose "Upload Artifact."


2 Answers

Have you considering using the Maven command-line to upload files?

mvn deploy:deploy-file \     -Durl=$REPO_URL \     -DrepositoryId=$REPO_ID \     -DgroupId=org.myorg \     -DartifactId=myproj \     -Dversion=1.2.3  \     -Dpackaging=zip \     -Dfile=myproj.zip 

This will automatically generate the Maven POM for the artifact.

Update

The following Sonatype article states that the "deploy-file" maven plugin is the easiest solution, but it also provides some examples using curl:

https://support.sonatype.com/entries/22189106-How-can-I-programatically-upload-an-artifact-into-Nexus-

like image 191
Mark O'Connor Avatar answered Sep 28 '22 21:09

Mark O'Connor


Using curl:

curl -v \     -F "r=releases" \     -F "g=com.acme.widgets" \     -F "a=widget" \     -F "v=0.1-1" \     -F "p=tar.gz" \     -F "file=@./widget-0.1-1.tar.gz" \     -u myuser:mypassword \     http://localhost:8081/nexus/service/local/artifact/maven/content 

You can see what the parameters mean here: https://support.sonatype.com/entries/22189106-How-can-I-programatically-upload-an-artifact-into-Nexus-

To make the permissions for this work, I created a new role in the admin GUI and I added two privileges to that role: Artifact Download and Artifact Upload. The standard "Repo: All Maven Repositories (Full Control)"-role is not enough. You won't find this in the REST API documentation that comes bundled with the Nexus server, so these parameters might change in the future.

On a Sonatype JIRA issue, it was mentioned that they "are going to overhaul the REST API (and the way it's documentation is generated) in an upcoming release, most likely later this year".

like image 44
Ed I Avatar answered Sep 28 '22 23:09

Ed I