Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy default-deploy on project

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project. Failed to deploy artifacts: Could not transfer artifactReturn code is: 401, ReasonPhrase: Unauthorized. -> [Help 1]


There was no changes made since last successful build. I double check settings.xml(username and password).Also check in pom.xml(distribution management)

I working on this issue since last 2 days.I gone through all the forum,nothing works.please help me out.

like image 670
Happy Avatar asked May 09 '16 22:05

Happy


2 Answers

This error message means your machine is not authenticating correctly to the Nexus machine. The credentials sent to Nexus from Maven are not correct.

When I have gotten this message, I usually have to look in my settings.xml to verify the proper credentials in this part. The username and password have to be the right ones as set in Nexus itself.

<servers>
    <server>
        <id>nexus-releases</id>
        <username>fillin</username>
        <password>fillin</password>
    </server>
</servers>

I usually go the Nexus GUI and try to log in with those credentials to verify them but it is possible to configure credentials that can publish via mvn but not log into the GUI.

One possible problem is if you are using dependency-management to identify where to deploy in case of "mvn deploy" target. There is a section like this:

<distributionManagement>
    <repository>
        <id>nexus-releases</id>
        <name>releases</name>
        <url>http://myNexus/more/stuff</url>
    </repository>
</distributionManagement>

and the id field has to match the the id on the credentials in the settings.xml. If the ids don't match, you will get this error.

Another possible problem is that if you are using an execution for the maven-deply-plugin in your pom.xml, you might have the configuration property

<repositoryId>nexus-releases</repositoryId> 

and again it doesn't match the id in the settings.xml so it fails with your error.

Similarly, if deploying using the command line option on the "mvn" command that looks like this

-DrepositoryId=nexus-releases

doesn't match the id in the settings.xml, again, it won't work.

like image 190
Lee Meador Avatar answered Oct 15 '22 07:10

Lee Meador


Following our discussion in the comments section, try to run this pom.xml

When the mvn goal should be : mvn deploy

The only two things you need is having a pom and passing the arguments:

This is the pom.xml you can use:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.hp.Maven</groupId>
    <artifactId>Maven-Nexus</artifactId>
    <packaging>pom</packaging>
    <version>1.0.0</version>

    <properties>
        <baseNexusURL>${baseNexusURL}</baseNexusURL>
        <targetRepositoryID>${repositoryId}</targetRepositoryID>
        <package.final.name>${project.artifactId}</package.final.name>
    </properties>

        <build> 
        <plugins>
            <plugin>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>2.8.2</version>
                <executions>
                    <execution>
                        <id>default-deploy</id>
                        <configuration>
                            <skip>true</skip>
                        </configuration>
                    </execution>
                    <execution>
                        <id>deploy-node-modules-artifact</id>
                        <phase>deploy</phase>
                        <goals>
                            <goal>deploy-file</goal>
                        </goals>
                        <configuration>
                            <file>${file}</file>
                            <groupId>${groupId}</groupId>
                            <artifactId>${artifactId}</artifactId>
                            <version>${version}</version>
                            <packaging>${packaging}</packaging>
                            <generatePom>true</generatePom>
                            <repositoryId>${targetRepositoryID}</repositoryId>
                            <url>${baseNexusURL}/content/repositories/${targetRepositoryID}</url>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

enter image description here

like image 21
Shahar Hamuzim Rajuan Avatar answered Oct 15 '22 06:10

Shahar Hamuzim Rajuan