how to upload JAR to Nexus OSS 3?
Asked Answered
B

3

9

How to perform an upload of a jar via curl the Nexus 3? I tried using the link tips but without success.

Here are my attempts:

curl -v -F r = -F releases hasPom = true and = -F jar -F file = @. / v12.1.0.1 / pom.xml -F file = @. / v12.1.0.1 / ojdbc7.jar -u admin: admin123 http: // localhost: 8081 / repository / maven releases

curl -v -F r = -F releases hasPom = false -F and -F jar = g = com.oracle.jdbc -F = ojdbc7 -F v = 1.0 p = -F jar -F file = @. / v12 .1.0.1 / ojdbc7.jar -u admin: admin123 http: // localhost: 8081 / repository / maven releases

Both have 400 Bad Request.

Bricebriceno answered 26/7, 2016 at 15:4 Comment(1)
Why do you have all that spaces in your parameters?Workout
I
-2

I've modified your code as below. Please try this.

curl -v -F r=releases -F hasPom=false -F e=jar -F g=com.oracle.jdbc -F a=ojdbc7 -F v=1.0 -F p=jar -F file=@"./v12.1.0.1/ojdbc7.jar" -u admin:admin123 http://localhost:8081/nexus/service/local/artifact/maven/content

Also I would suggest using the full path rather than relative path. Can you share where you are using this curl snippet? Any CI tool like Jenkins?

Indefensible answered 8/8, 2016 at 7:25 Comment(3)
URL "service/local/artifact" is not supported in Nexus v3.Readjustment
@Readjustment can you confirm if this rest end point has been removed in OSS3? I'll change to the same.Indefensible
The path where the file is uploaded has changed when compared to Nexus 2 - now it's /repository/<repo-id>/<full-path-of-file-including-group-and-version> e.g. /repository/snapshots/com/foo/bar/1.0.0-SNAPSHOT/baz-1.0.0-SNAPSHOT.pom. See support.sonatype.com/hc/en-us/articles/… for details.Cloth
R
10

Contents of directory

cert_for_nexus.pem

curl.exe

pom.xml

utils-1.0.jar

Nexus v3 is configured for http

curl -v -u admin:admin123 --upload-file pom.xml http://localhost:8081/nexus/repository/maven-releases/org/foo/utils/1.0/utils-1.0.pom

curl -v -u admin:admin123 --upload-file utils-1.0.jar http://localhost:8081/nexus/repository/maven-releases/org/foo/utils/1.0/utils-1.0.jar

Nexus v3 is configured for https

  • prerequisite: must have curl with SSL enabled (link - left menu)

curl -v --cacert cert_for_nexus.pem -u admin:admin123 --upload-file pom.xml https://localhost:8443/nexus/repository/maven-releases/org/foo/utils/1.0/utils-1.0.pom

curl -v --cacert cert_for_nexus.pem -u admin:admin123 --upload-file utils-1.0.jar https://localhost:8443/nexus/repository/maven-releases/org/foo/utils/1.0/utils-1.0.jar

Contents of pom.xml

<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>org.foo</groupId>
  <artifactId>utils</artifactId>
  <version>1</version>
</project>

EDIT: fixed -u order for both https examples

Readjustment answered 19/10, 2016 at 11:52 Comment(0)
C
2

You could use nexus-cli.

docker run -ti -v $(pwd):$(pwd):ro sjeandeaux/nexus-cli:0.2.0 \
                          -repo=http://nexus:8081/repository/maven-releases \
                          -user=admin \
                          -password=admin123 \
                          -file=$(pwd)/upload.jar \
                          -groupID=your.group \
                          -artifactID=yourArtifactID \
                          -version=0.1.0 \
                          -hash md5 \
                          -hash sha1
Columba answered 19/9, 2017 at 20:9 Comment(0)
I
-2

I've modified your code as below. Please try this.

curl -v -F r=releases -F hasPom=false -F e=jar -F g=com.oracle.jdbc -F a=ojdbc7 -F v=1.0 -F p=jar -F file=@"./v12.1.0.1/ojdbc7.jar" -u admin:admin123 http://localhost:8081/nexus/service/local/artifact/maven/content

Also I would suggest using the full path rather than relative path. Can you share where you are using this curl snippet? Any CI tool like Jenkins?

Indefensible answered 8/8, 2016 at 7:25 Comment(3)
URL "service/local/artifact" is not supported in Nexus v3.Readjustment
@Readjustment can you confirm if this rest end point has been removed in OSS3? I'll change to the same.Indefensible
The path where the file is uploaded has changed when compared to Nexus 2 - now it's /repository/<repo-id>/<full-path-of-file-including-group-and-version> e.g. /repository/snapshots/com/foo/bar/1.0.0-SNAPSHOT/baz-1.0.0-SNAPSHOT.pom. See support.sonatype.com/hc/en-us/articles/… for details.Cloth

© 2022 - 2024 — McMap. All rights reserved.