Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploying artifacts in nexus from maven gives error "Return code is: 401"?

Tags:

maven

nexus

I am getting 401 error while deploying in nexus. I does not make any changes to the installed nexus. Nexus is running on localhost:8080/nexus and i am able to login with default user/password. When i am running mvn deploy i am getting this error.

Here is my POM.

 <groupId>testproject</groupId>
 <artifactId>testproject</artifactId>
 <packaging>jar</packaging>
 <version>1.0-SNAPSHOT</version>
 <name>testproject</name>
 <url>http://maven.apache.org</url>
 <distributionManagement>
  <repository>
      <id>releases</id>
      <url>http://localhost:8080/nexus/content/repositories/releases</url>
    </repository>
    <snapshotRepository>
       <id>snapshots</id>
       <url>http://localhost:8080/nexus/content/repositories/snapshots</url>
    </snapshotRepository>
</distributionManagement>
<dependencies>
 .........
</dependencies>

and ~/.m2/settings.xml

<servers>
    <server>
        <id>snapshots</id>
        <username>deployment</username>
        <password>deployment123</password>
    </server>
    <server>
        <id>releases</id>
        <username>deployment</username>
        <password>deployment123</password>
    </server>
</servers>

Exception:

Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-           deploy) on project testproject: Failed to deploy artifacts: Could not transfer artifact testproject:testproject:jar:1.0-20131213.150615-1 from/to snapshots (http://localhost:8080/nexus/content/repositories/snapshots): Failed to transfer file: http://localhost:8080/nexus/content/repositories/snapshots/testproject/testproject/1.0-SNAPSHOT/testproject-1.0-20131213.150615-1.jar. 
Return code is: 401 -> [Help 1]

Please help me.

like image 995
Gangaraju Avatar asked Dec 13 '13 15:12

Gangaraju


People also ask

Why deploy artifacts in Nexus for deployment?

Nexus is a repository manager that stores “artifacts”, which allows you to proxy collect and manage your dependencies, making it easy to distribute your software.

What is Maven 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.


2 Answers

It's working now. Need to edit ${MVN_HOME}/conf/settings.xml instead of /home/{user}/.m2/settings.xml

like image 121
Gangaraju Avatar answered Oct 25 '22 02:10

Gangaraju


HTTP 401 is the status code for "unauthorized", which implies that your deployment user isn't authorized to upload artifacts to that particular repository in Nexus. Log in to Nexus and give the deployment user the role(s) required to to change that snapshot repo.

like image 25
Kelsey Francis Avatar answered Oct 25 '22 01:10

Kelsey Francis