Trying to get Maven to deploy to Artifactory Server

David W. picture David W. · Feb 18, 2015 · Viewed 21.1k times · Source

I'm trying to get a project to deploy to our Artifactory repository. The user qazwart is an administrator and has the permission to deploy to the server. I have that user's correct information in the settings.xml file under the <central> and <snapshots> IDs. I have the right URL in the <distributionManagement> section in my pom.xml file. It looks like everything is setup correctly. Yet, when I try to deploy, I get a Return code is: 405, ReasonPhrase: Method Not Allowed. -> [Help 1] error.

What should I be looking for or trying?

The output of mvn deploy (I added line breaks in the [ERORR] section to make it more readable):

$ mvn deploy
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO] 
[INFO] ....
[INFO] ------------------------------------------------------------------------
[INFO] Building Project Aggregate POM 2.5.2
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-install-plugin:2.3.1:install (default-install) @ rez ---
[INFO] Installing /home/qazwart/project/workspace/pom.xml to \
/home/tomcat/.m2/repository/com/vegicorp/proj/2.5.2/proj-2.5.2.pom
[INFO] 
[INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ proj ---
Uploading: http://repo.vegicorp.net/artifactory/libs-release/net/vegicorp/proj/2.5.2/proj-2.5.2.pom
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] Project Aggregate POM ........................ FAILURE [1.984s]
[INFO] ....
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.885s
[INFO] Finished at: Wed Feb 18 12:58:53 EST 2015
[INFO] Final Memory: 10M/149M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal \
org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy \
(default-deploy) on project proj: \
Failed to deploy artifacts: Could not transfer artifact \
net.vegicorp:proj:pom:2.5.2 from/to central \
(http://repo.vegicorp.net/artifactory/libs-release): \
        Failed to transfer file: \
http://repo.vegicorp.net/artifactory/libs-release/net/vegicorp/proj/2.5.2/proj-2.5.2.pom. \
Return code is: 405, ReasonPhrase: Method Not Allowed. -> [Help 1]
[INFO] ...
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

My settings file in $HOME/.m2/settings.xml is:

<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <proxies>
    <proxy>
      <id>proxy</id>
      <active>true</active>
      <protocol>http</protocol>
      <host>proxy.vegicorp.net</host>
      <port>3128</port>
      <nonProxyHosts></nonProxyHosts>
    </proxy>
  </proxies>

  <servers>
    <server>
      <username>qazwart</username>
      <password>swordfish</password>
      <id>central</id>
    </server>
    <server>
      <username>qazwart</username>
      <password>swordfish</password>
      <id>snapshots</id>
    </server>
  </servers>

  <profiles>
    <profile>
      <repositories>
        <repository>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
          <id>central</id>
          <name>libs-release</name>
          <url>http://repo.vegicorp.net/artifactory/libs-release</url>
        </repository>
        <repository>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
          <id>snapshots</id>
          <name>libs-snapshot</name>
          <url>http://repo.vegicorp.net/artifactory/libs-snapshot</url>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
          <id>central</id>
          <name>plugins-release</name>
          <url>http://repo.vegicorp.net/artifactory/plugins-release</url>
        </pluginRepository>
        <pluginRepository>
          <snapshots />
          <id>snapshots</id>
          <name>plugins-snapshot</name>
          <url>http://repo.vegicorp.net/artifactory/plugins-snapshot</url>
        </pluginRepository>
      </pluginRepositories>
      <id>artifactory</id>
    </profile>
  </profiles>
  <activeProfiles>
    <activeProfile>artifactory</activeProfile>
  </activeProfiles>
</settings>

And my Project POM is:

<?xml version="1.0" encoding="UTF-8"?>
<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>
  <artifactId>proj</artifactId>
  <groupId>net.vegicorp</groupId>
  <version>2.5.2</version>
  <packaging>pom</packaging>    

  <name>Project Aggregate POM</name>
  <description>All Reservation Delivery Projects</description>

  <properties>
    ....
  </properties>

  <scm>
    ....
  </scm>
  <distributionManagement>
    <repository>
      <id>central</id>
      <name>libs-release</name>
      <url>http://repo.vegicorp.net/artifactory/libs-release</url>
    </repository>
    <snapshotRepository>
      <id>snapshots</id>
      <name>libs-snapshot</name>
      <url>http://repo.vegicorp.net/artifactory/libs-snapshot</url>
    </snapshotRepository>
  </distributionManagement>

  <dependencyManagement>
    ....
  </dependencyManagement>

  <build>
    ...
  </build>

  <modules>
    ...
  </modules>
</project>

Answer

David W. picture David W. · Feb 18, 2015

I found the issue. I had the wrong Artifactory repositories. I had lib-releases and lib-snapshots. These are virtual repositories. What I want is libs-release-local and libs-snapshot-local. Now, mvn deploy works.

However, I now am trying to get the Jenkin's Artifactory Plugin