无法将Maven jar部署到Azure DO存储库 [英] Unable to deploy a Maven jar to Azure DO repository
问题描述
我无法在Azure devops存储库中部署独立的jar文件.使用以下命令在maven上调用deploy插件:
I am unable to deploy a standalone jar file in Azure devops repository. Using the following command to invoke the deploy plugin on maven:
mvn deploy:deploy-file -Dpackaging="jar" -DrepositoryId="MAVENREPO" -Durl="https://pkgs.dev.azure.com/XXXXXXXXXXXXXXX/q6f55433-87d0-4c87-a6ab-7d5c19f9088b/_packaging/MAVENREPO/maven/v1" -DgroupId="agile" -DartifactId="AgileAPI" -Dversion="1.0" -Dfile="AgileAPI.jar"
我收到以下错误.似乎文件正在上载到Azure存储库,但由于某种原因无法部署.任何指针将不胜感激.
And I am getting the following error. It appears that the file is being uploaded to Azure repository but somehow failing to deploy. Any pointers will be appreciated.
我已经使用上面显示的maven命令和调用deploy插件的pom.xml文件进行了尝试.结果是一样的.
I have tried this both with a maven command as shown above and with the pom.xml file invoking the deploy plugin. The result is the same.
Uploading to MAVENREPO: https://pkgs.dev.azure.com/XXXXXXXXXXXXXXX/q6f55433-87d0-4c87-a6ab-7d5c19f9088b/_packaging/MAVENREPO/maven/v1/agile/AgileAPI/1.0/AgileAPI-1.0.jar
Uploading to MAVENREPO: https://pkgs.dev.azure.com/XXXXXXXXXXXXXXX/q6f55433-87d0-4c87-a6ab-7d5c19f9088b/_packaging/MAVENREPO/maven/v1/agile/AgileAPI/1.0/AgileAPI-1.0.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12.221 s
[INFO] Finished at: 2021-02-09T21:21:43-05:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy-file (default-cli) on project standalone-pom: Failed to deploy artifacts: Could not find artifact agile:AgileAPI:jar:1.0 in MAVENREPO (https://pkgs.dev.azure.com/XXXXXXXXXXXXXXX/q6f55433-87d0-4c87-a6ab-7d5c19f9088b/_packaging/MAVENREPO/maven/v1) -> [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
推荐答案
将第3方程序集发布到Azure Artifact中的Maven提要的命令如下:
The command to publish a 3rd party assembly to a Maven feed in Azure Artifact is as below:
mvn deploy:deploy-file -Dpackaging="jar" -DrepositoryId="MyFeedName" -Durl="MyFeedURL" -DgroupId="MyGroup" -DartifactId="myFirstApp" -Dversion="jarFileVersion" -Dfile="jarFileLocalPath"
我已经通过运行以下命令生成的Maven工件进行了测试:
I've tested on my side with the Maven artifact generated by running the following command:
mvn -B archetype:generate -DarchetypeGroupId="org.apache.maven.archetypes" -DgroupId="MyGroup" -DartifactId="myFirstApp"
并通过以下命令获得成功的结果:
and got a successful result with the command below:
mvn deploy:deploy-file -Dpackaging="jar" -DrepositoryId="{MyFeedName}" -Durl="https://pkgs.dev.azure.com/{org}/TestCase/_packaging/{MyFeedName}/maven/v1" -DgroupId="MyGroup" -DartifactId="myFirstApp" -Dversion="1.0-SNAPSHOT" -Dfile="C:\Users\{username}\myFirstApp\src\main\java\MyGroup\App.java"
注意:
您需要:
1.在 $ {user.home}/.m2
中添加 settings.xml
文件:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>[MyFeedName]</id>
<username>[ORG]</username>
<password>[PERSONAL_ACCESS_TOKEN]</password>
</server>
</servers>
</settings>
2.将仓库添加到您的 pom.xml
文件中:
2 . Add the repo to your pom.xml
file:
<repository>
<id>[FEEDNAME]</id>
<url>https://pkgs.dev.azure.com/{ORG}/{PROJECTNAME}/_packaging/{FEEDNAME}n/maven/v1</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
您可以按照我的步骤进行操作,以查看命令中是否指定了错误的参数.
You could follow my step, to see whether you specify wrong parameter in the command.
有用的博客:
https://docs.microsoft.com/en-us/azure/devops/artifacts/maven/publish?view = azure-devops
这篇关于无法将Maven jar部署到Azure DO存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!