Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mvn deploy:deploy-file -- Failed to deploy artifacts: Could not find artifact

Tags:

maven

nexus

I am trying to add a 3rd party vendor's jar to our internal nexus repository.

I have tried to do so using this command:

mvn deploy:deploy-file 
-DgroupId=acme 
-DartifactId=acme 
-Dversion=1.0 
-Dpackaging=jar 
-Dfile=C:\tmp\acme-1.0.jar 
-DrepositoryId=Nexus 
-Durl=http://myserver:8888/nexus/content/repositories/thirdparty/

With the following entry in my settings.xml:

  <servers>
        <server>
            <id>Nexus</id>
            <username>myusername</username>
            <password>mypassword</password>
        </server>
  </servers>

But I get this error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:
deploy-file (default-cli) on project standalone-pom: Failed to deploy artifacts:
 Could not find artifact acme:acme:jar:1.0 in Nexus (http://myserver:8888/nexus/c
ontent/repositories/thirdparty) -> [Help 1]

Any suggestions?

Some related info... I can install to my local repository just fine, using this command:

mvn install:install-file 
-DgroupId=acme 
-DartifactId=acme 
-Dversion=1.0 
-Dpackaging=jar 
-Dfile=C:\tmp\acme-1.0.jar

I have also tried 'Artifact Upload' via the Nexus web interface, using GAV parameters:

Group: acme
Artifact: acme
Version: 1.0
Packaging: jar

And selecting & adding the acme-1.0.jar. This completes fine, but "mvn install" on the project depending on this jar results in:

Could not find artifact acme:acme:jar:1.0 in Nexus (http://myserver:8888/nexus/content/groups/public)

My pom contains:

<repositories>
  <repository>
    <id>Nexus</id>
    <url>http://myserver:8888/nexus/content/groups/public</url>
    <releases><enabled>true</enabled></releases>
    <snapshots><enabled>true</enabled></snapshots>
  </repository>
</repositories>

Any help much appreciated...

PS I know this question is very similar to this one, but the issue there seemed to be the use of a jenkins url, instead of a nexus url.

like image 236
Shaun Abram Avatar asked Apr 25 '13 15:04

Shaun Abram


People also ask

How do you deploy artifacts?

To deploy an artifact bundle, in the Deploy dialog, first upload the archive file you want to deploy. Check the Deploy as Bundle Artifact checkbox and click Deploy.

What is mvn deploy?

The deploy plugin is primarily used during the deploy phase, to add your artifact(s) to a remote repository for sharing with other developers and projects. This is usually done in an integration or release environment.


1 Answers

Answering my own question. I resolved this as follows:

1) If you are behind a proxy server (i.e. you have a proxy server setup in your maven settings.xml) but your nexus server is internal, you may need to add the nexus server as a nonProxyHost in settings.xml e.g.

<proxies>
  <proxy>
    ...
    <nonProxyHosts>myserver</nonProxyHosts>
  </proxy>
</proxies>

I realized I needed to do this because the "mvn deploy:deploy-file" command I was running did not seem to be reaching the nexus repo at all. For example, I could change the repo id, username or password in the server section of my settings.xml, and still get exactly the same error. I could also change the url in the deploy command to gibberish (For example to -Durl=notexist), or even completely shutdown my nexus repo, and STILL get the same error.

2) Make sure your 3rd party repository is set up as Release, rather than Snapshot. To do this, go to the web GUI, select Configuration tab of the 3rd party repository, and make sure that Repository Policy is set to to Release.

I found this out by looking at the catalina.out log (I run nexus as a war in Tomcat) and seeing the following:

ERROR org.sonatype.nexus.rest.ContentPlexusResource - Got exception during processing request "PUT http://myserver:888/nexus/content/repositories/thirdparty/acme/acme/1.0/acme-1.0.pom": Storing of item thirdparty:/acme/acme/1.0/acme-1.0.pom is forbidden by Maven Repository policy. Because thirdparty is a SNAPSHOT repository

With those 2 fixes in place, both the "mvn deploy:deploy-file" command, and uploading via the 'Upload Artifacts' option in the web GUI work.

like image 172
Shaun Abram Avatar answered Sep 26 '22 02:09

Shaun Abram