1

I'm currently working on getting a script to upload my artifacts to Nexus using CURL.

I can get it to work with one artifact file without any problems using the command:

curl -v -F r={repo_id} -F hasPom=true -F e=jar -F file=@pom.xml -F file=@target/project.jar -u un:pwd {repo_url}

My project has both a jar containing the binaries and a jar containing the sources though. I would like to deploy both to the same location in my maven repo. I tried this with the curl command by adding a second file,

curl -v -F r={repo_id} -F hasPom=true -F e=jar -F file=@pom.xml -F file=@target/project.jar -F file=@target/project-sources.jar -u un:pwd {repo_url}

This essentially performs two seperate rest calls for each file, using the same pom. Which doesn't work since my Nexus doesn't allow updating artifacts.

Is there a way to make this work, or can this only work by enabling the updating of artifacts? I would prefer not to enable this for obvious reasons.

Baris Demiray
  • 1,539
  • 24
  • 35
Ractoc
  • 239
  • 2
  • 9
  • Can you not use the Maven Deploy plugin instead of curl: http://maven.apache.org/plugins/maven-deploy-plugin/ ? – DarthHater Oct 27 '16 at 20:23
  • We tried using the maven deploy plugin but we're running into a known issue when using maven deploy in combination with Jenkins. About 50% of the time, we run into a fatal error: "missing class X". When we lookup class X in our local maven repo, it IS there. So maven deploy is not working for us.This is why we are looking at alternate solutions. For now, I just disabled uploading the source jars, but we do need a work around for this. – Ractoc Oct 28 '16 at 07:00
  • What about using Aether? – J Fabian Meier Oct 31 '16 at 10:07

2 Answers2

0

Just add -Dsources=${YourSourceJar} to your curl command.

Tunaki
  • 132,869
  • 46
  • 340
  • 423
jordanwilson230
  • 355
  • 3
  • 4
0

I know this is an old issue, but I wanna add this.

I've run into the same issues/problems during the past days. To be honest, I couldn't find a solution to upload multiple jars with same pom.xml through curl. I ended up using maven deploy-plugin. Please see my solution here.

Note: If you want to upload jars with multiple classifiers without the pom.xml - this can be achieved through the rest api.

Marius Manastireanu
  • 2,461
  • 5
  • 19
  • 29