I have maven repository in Artifactory. I want to upload pom file and zip file (package from a source code) using the maven deploy command. I don't want to do it using the curl (which works by the way), but I am trying to achieve the same thing in maven.
I have a settings.xml
<settings>
<interactiveMode>false</interactiveMode>
<profiles/>
<servers>
<server>
<id>maven-snapshot-local</id>
<username>svcjenkins</username>
<password>***</password>
</server>
</server></servers>
</settings>
I have pom.xml
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>fa</groupId>
<artifactId>FIXCommon</artifactId>
<version>LATEST-SNAPSHOT</version>
<packaging>pom</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.6</version>
<configuration>
<groupId>fa</groupId>
<artifactId>FIXCommon</artifactId>
<version>LATEST-SNAPSHOT</version>
<packaging>zip</packaging>
<file>fix-common.zip</file>
<url>https://artifactory.domain.dev/artifactory/maven-snapshot-local</url>
</configuration>
</plugin>
</plugins>
</build>
</project>`
I run command:
mvn -U -X clean install deploy:deploy-file
And the error is:
Caused by: org.apache.maven.plugin.MojoExecutionException: Failed to retrieve remote metadata fa:FIXCommon:LATEST-SNAPSHOT/maven-metadata.xml: Could not transfer metadata fa:FIXCommon:LATEST-SNAPSHOT/maven-metadata.xml from/to remote-repository (https://artifactory.domain.dev/artifactory/maven-snapshot-local): authentication failed for https://artifactory.domain.dev/artifactory/maven-snapshot-local/fa/FIXCommon/LATEST-SNAPSHOT/maven-metadata.xml, status: 401 Unauthorized`
when I try the same with curl it passes:
curl -u user:pass fix-common.zip https://artifactory.domain.dev/artifactory/maven-snapshot- local/fa/FIXCommon/LATEST-SNAPSHOT/fix-common.zip
Can you please take a look on my XML definitions and tell me if I have missed anything?
Solution was to include repositoryId fields in pom definition as well.
<distributionManagement>
<repository>
<id>maven-snapshot-local</id>
<url>https://artifactory.domain.dev/artifactory/maven-snapshot-local</url>
</repository>
</distributionManagement>
<build>
<plugins>
<plugin>
............
<configuration>
<repositoryId>maven-snapshot-local</repositoryId>