简体   繁体   中英

How to use azure pipeline to deploy jar files to azure artifact using maven task

I created an azure artifact and add it to pom.xml and I configure ~/.m2/settings.xml in the agent machine with the token. and when I deploy locally it is work but when I use the maven task in the azure pipeline this error appears. user has all permissions

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:3.0.0:deploy (default-deploy) on project my-server: Failed to deploy artifacts: Could not transfer artifact:pom:1.0 from/to artifact authorization failed for https://pkgs.dev.azure.com/, status: 403 Forbidden - User '7ba7a839-2613-4554-84a4-4aa2d4cf4162' lacks permission to complete this action. You need to have 'AddPackage'. (DevOps Activity ID: 46D5F76C-E82C-48C8-8D63-4269F3CE4F65) -> [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

i try in windows it worked successfully but i use Linux centos7 as agent to run my pipeline

You can try to add a Maven Authenticate task before the Maven task .

When running the pipeline job on the agent, the Maven Authenticate task will search for the settings.xml file in the current user's home directory on the agent machine. For Linux and Mac, the path is $HOME/.m2/settings.xml . For Windows, the path is %USERPROFILE%\.m2\settings.xml . If the settings.xml file doesn't exist, a new one will be created at that path for use.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM