I have a Maven project that's using an externally provided parent POM package and I want to upload only the parent POM to Azure Artifacts.
As recommended by Microsoft (https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/maven-authenticate-v0?view=azure-pipelines#authenticate-maven-feeds-inside-your-organization), I'm trying to achieve this by using the following command:
mvn deploy:deploy-file -DgroupId=biz.org.aem -DartifactId=aem-cloud-parent -Dpackaging=pom -Dfile=/path-to/artifacts/aem-cloud-parent.pom -DrepositoryId=my-azure-feed-id -Durl=https://pkgs.dev.azure.com/my-org/my-project/_packaging/my-feed/maven/v1
The deploy plugin already exists in my local .m2 repository, but Maven is still trying to download it from a remote repository and failing due to a 401 Unauthorized error:
[INFO] Artifact org.apache.maven.plugins:maven-clean-plugin:pom:3.2.0 is present in the local repository, but cached from a remote repository ID that is unavailable in current build context, verifying that is downloadable from [az-profile (https://pkgs.dev.azure.com/my-org/my-project/_packaging/my-feed/maven/v1, default, releases+snapshots)]
[WARNING] org.apache.maven.plugins/maven-metadata.xml failed to transfer from https://pkgs.dev.azure.com/my-org/my-project/_packaging/my-feed/maven/v1 during a previous attempt. This failure was cached in the local repository and resolution will not be reattempted until the update interval of az-profile has elapsed or updates are forced. Original error: Could not transfer metadata org.apache.maven.plugins/maven-metadata.xml from/to az-profile (https://pkgs.dev.azure.com/my-org/my-project/_packaging/my-feed/maven/v1): status code: 401, reason phrase: Unauthorized (401)
[ERROR] No plugin found for prefix 'deploy' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/Users/local/.m2/repository), az-profile (ttps://pkgs.dev.azure.com/my-org/my-project/_packaging/my-feed/maven/v1)] -> [Help 1]
How can I resolve this to successfully deploy this file to my Azure feed?
Ah, the reason for this issue has made me want to beat my head against the wall. For some reason, the -DrepositoryId
parameter can't find the repository if you actually give it the ID of the Azure feed. You have to give it the name instead. I can't explain how frustrating this has been. In the Azure CLI, it accepts the feed ID too but seems Maven doesn't.