[Maven 3] Fail to deploy to azure feeds
See original GitHub issueRequired Information
Question, Bug, or Feature?
Type: Bug
Enter Task Name: Maven 3
Environment
- Server - Azure Pipelines or TFS on-premises?
- Azure Pipelines
- MyCompany/MyCompany/Pipeline-Java(Edit: sorry I have to hide the real project because security requirement)
- Agent - Hosted or Private:
- Hosted agent, Hosted Ubuntu 1604
Issue Description
We try to leverage the nice feature ‘Authenticate built-in Maven feeds’ for our java project, but it fails to authenticate with Azure feeds. After some tests, we found the following facts:
- POM1:
<profiles>
<profile>
<id>azure</id>
<distributionManagement>
<repository>
<id>visualstudio-com-mycompany</id>
<url>https://mycompany.pkgs.visualstudio.com/_packaging/one/maven/v1</url>
</repository>
</distributionManagement>
<repositories>
<repository>
<id>visualstudio-com-mycompany</id>
<url>https://mycompany.pkgs.visualstudio.com/_packaging/one/maven/v1</url>
</repository>
</repositories>
</profile>
</profiles>
- POM2
<project>
......
<distributionManagement>
<repository>
<id>visualstudio-com-mycompany</id>
<url>https://mycompany.pkgs.visualstudio.com/_packaging/one/maven/v1</url>
</repository>
</distributionManagement>
<repositories>
<repository>
<id>visualstudio-com-mycompany</id>
<url>https://mycompany.pkgs.visualstudio.com/_packaging/one/maven/v1</url>
</repository>
</repositories>
.....
</project>
You can see, the difference is if <distributionManagement> and <repositories> are defined in <profile> or not
- Run ‘mvn deploy’ locally, both cases work fine. Of course, we set the correct credentials in local setting.xml
- Build from Azure pipeline, POM1 throws ‘Not authorized’ error while POM2 runs successfully as expected.
Error logs
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project helloworld: Failed to retrieve remote metadata helloworld:helloworld:1.0-SNAPSHOT/maven-metadata.xml: Could not transfer metadata helloworld:helloworld:1.0-SNAPSHOT/maven-metadata.xml from/to visualstudio-com-one (https://mycompany.pkgs.visualstudio.com/_packaging/one/maven/v1): Not authorized -> [Help 1] |
-- | --
| [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 |
| /usr/share/apache-maven-3.6.1/bin/mvn failed with return code: 1 |
| Could not retrieve code analysis results - Maven run failed. |
| ##[error]Build failed.
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (5 by maintainers)
Top Results From Across the Web
[Maven 3] Fail to deploy to azure feeds - Visual Studio Feedback
We try to leverage the nice feature 'Authenticate built in Maven feeds' for our java project, but it fails to authenticate with Azure...
Read more >Maven@3 - Maven v3 task | Microsoft Learn
Build, test, and deploy with Apache Maven (task version 3). ... Skip generating effective POM while authenticating built-in feeds.
Read more >Unable to deploy a Maven jar to Azure DO repository
The command to publish a 3rd party assembly to a Maven feed in Azure Artifact is as below: mvn deploy:deploy-file -Dpackaging="jar" ...
Read more >Artifactory Azure DevOps Extension - JFrog Documentation
The JFrog Artifactory extension for Azure DevOps supports: Resolving your build dependencies from Artifactory. Deploying your build ...
Read more >Integrating Azure Repos and Azure Pipelines with Eclipse
Overview. Azure DevOps services helps teams modernize their application development lifecycle and go from idea to deployment with continuous ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@elbatk You’re correct, however they will have to setup a “Maven” “Service Connection” to be able to add to the maven authenticate task.
@tao-zhang Yes, for Nexus, you should be able to setup a “Service Connection” to add that password to your settings.xml file. For your case follow these steps.
Once this is setup, the build agent will add the new Nexus connection to the settings.xml file with the password or auth token. You can read more about Service Connections here.
@tao-zhang glad it helped. We’d welcome any feedback on the documentation or on the new task. I am closing this issue as fixed.