0

I am trying to publish third-party private package directly to my Azure Artifacts feed with mvn deploy:deploy-file command like this:

mvn deploy:deploy-file -Dpackaging="jar" -DrepositoryId="PXXXXX-inccoming" -Durl="https://pkgs.dev.azure.com/XxxXxxxXxxx/XxxXxx/_packaging/PXXXXX-incoming/maven/v1" -DgroupId="pl.group.id" -DartifactId="artifact" -Dversion="0.0.2" -Dfile="C:\path\pl\group\id\0.0.2\artifact-0.0.2.jar"

But I am getting strange error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy-file (default-cli) on project CAST_2015: Failed to deploy artifacts: Could not transfer artifact pl.group.id:artifact:jar:0.0.2 from/to PXXXXX-inccoming (https://pkgs.dev.azure.com/XxxXxxxXxxx/XxxXxx/_packaging/PXXXXX-incoming/maven/v1): Transfer failed for https://pkgs.dev.azure.com/XxxXxxxXxxx/XxxXxx/_packaging/PXXXXX-incoming/maven/v1/pl/group/id/artifact/0.0.2/artifact-0.0.2.jar 401 Unauthorized ProxyInfo{host='proxy-host', userName='null', port=8080, type='http', nonProxyHosts='null'}

The provided user has full access for packaging in Azure.

Both proxy and server settings are actually in my setting.xml file. What am I doing wrong?

James Z
  • 12,209
  • 10
  • 24
  • 44
Shafter
  • 13
  • 6

1 Answers1

0

Azure Artifacts deploy packages

When we receiving a 401 it is because maven is sending the wrong login credentials, or no credentials at all.

To resolve this issue, please add the following configuration to the <servers>...</servers> configuration node in the maven setting configuration file:

<server>
      <id>releases</id>
      <username>admin</username>
      <password>admin123</password>
    </server>
    <server>
      <id>snapshots</id>
      <username>admin</username>
      <password>admin123</password>
    </server>
  </servers>

Note:

  • The id configured in setting.xml must be the same as the id configured in pom.xml.
  • If you try to publish something to a releases repository and that version already exists in the repository

If it not work for you, please check below thread for some more details:

Why am I getting a "401 Unauthorized" error in Maven?

Leo Liu
  • 71,098
  • 10
  • 114
  • 135