question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Maven 3] Fail to deploy to azure feeds

See original GitHub issue

Required 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:closed
  • Created 4 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
aasimcommented, Sep 24, 2019

@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.

  1. Go to “Project Settings” > “Service Connections”, and add a new service connection of type “Maven”. image
  2. Fill out the details for the service connection, making sure the repository id matches the repostiory id in your pom.xml image
  3. In your “Maven Authenticate” task, select your service connection from the “Credentials for repositories outside this organization/collection” dropdown. image

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.

0reactions
aasimcommented, Sep 26, 2019

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found