Reputation: 425
I want to publish jar to Nexus snapshot repository.
If you know how to realize, I would like to know.
I'm planning to publish Java project artifacts (jar) using Gradle from the Jenkins Pipeline to the Nexus3 artifact repository. (But on requirements
I can not use the maven-publish
plugin forbuild.gradle
. Using maven-publish
asgradle publish
, I confirms that I can publish to the snapshot repository)
I will publish jar from a Jenkins job.
I would like to publish to snapshot repository , but I was not able to investigate / implement various things.
According to my research, it seems that there is already the following Jenkins Plugin
However, neither plug-in seems to support Publish to the snapshot repository. (I tried for a while, but I got an error)
Also, calling API in the JenkinsPipeline script using curl
was not permitted as follows:
sh "curl -v -u admin:admin123 \
-X POST http://localhost:8081/service/rest/v1/components?repository=maven=snapshots \
-F maven2.groupId=${groupId} \
-F maven2.artifactId=${artifactId} \
-F maven2.version=${version} \
-F maven2.asset1=build/libs/${artifactId}-${version}.jar \
-F maven2.asset1.extension=jar \
-F maven2.asset2=build/libs/${artifactId}-${version}.jar \
-F maven2.asset2.classifier=javadoc \
-F maven2.asset2.extension=jar \
-F maven2.asset3=build/libs/${artifactId}-${version}.jar \
-F maven2.asset3.classifier=sources \
-F maven2.asset3.extension=jar"
}
The error message when curling is as follows.
* Server auth using Basic with user 'admin'
> POST /service/rest/v1/components?repository=maven-snapshots HTTP/1.1
> Host: localhost:8081
> Authorization: Basic YWRtaW46YWRtaW4xMjM=
> User-Agent: curl/7.55.1
> Accept: */*
> Content-Length: 1379
> Expect: 100-continue
> Content-Type: multipart/form-data; boundary=------------------------bea51339dc9456fe
>
< HTTP/1.1 100 Continue
} [1379 bytes data]
< HTTP/1.1 400 Bad Request
< Date: Sat, 13 Jul 2019 11:18:22 GMT
< Server: Nexus/3.17.0-01 (OSS)
< X-Content-Type-Options: nosniff
< Vary: Accept
< Content-Type: application/vnd.siesta-validation-errors-v1+json
< X-Siesta-FaultId: 2281dcfa-6583-456a-9970-318d54dd431b
< Content-Length: 93
* HTTP error before end of send, stop sending
<
{ [93 bytes data]
100 1472 100 93 100 1379 93 1379 0:00:01 --:--:-- 0:00:01 2944
* Closing connection 0
[{"id":"*","message":"Upload to snapshot repositories not supported, use the maven client."}][Pipeline] error
Thank you.
Upvotes: 1
Views: 5037
Reputation: 24
I was having this problem as well. What worked for me was making sure the version number had '-SNAPSHOT' at the end of it, like so: 'com.ex.example-1.0.3-SNAPSHOT' You cannot post a non-snapshot artifact to a snapshot repository in Nexus, and the same goes for a release repository.
Upvotes: 0