Unauthorized (401): While deploying mule maven artifacts to GitLab maven repository
Summary
While using the Mule maven plugin to create and deploy the packages to the GitLab maven repository, the GitLab CI job is throwing a 401 Unauthorized error.
Steps to reproduce
deploy:
script:
- 'cp ci_settings.xml /root/.m2/settings.xml'
- cat /root/.m2/settings.xml
- 'mvn deploy:deploy-file -Dfile=mule-template-app-1.0.3-SNAPSHOT-mule-xxx.jar -Durl=https://gitlab.com/api/v4/projects/xxxxx/packages/maven -DrepositoryId=gitlab-maven -DgroupId=com.xxx.xxx.xxx.xxx -DartifactId=mule-template-app -Dpackaging=mule-application -Dversion=1.0.3-SNAPSHOT'
only:
- master
image: maven:latest
<settings>
<servers>
<server>
<id>gitlab-maven</id>
<configuration>
<httpHeaders>
<property>
<name>Job-Token</name>
<value>${env.CI_JOB_TOKEN}</value>
</property>
</httpHeaders>
</configuration>
</server>
</servers>
</settings>
Example Project
- Sample Repo: https://gitlab.com/s_shaik/maven-401
- Failed Jobs:
What is the current bug behavior?
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy-file (default-cli) on project mule-4-template-project-F2: Failed to deploy artifacts: Could not transfer artifact 0dd19ae0743567:xxxxx-project-F2:jar:1.0.3 from/to gitlab-maven (https://gitlab.com/api/v4/projects/xxxxx/packages/maven): Unauthorized (401) -> [Help 1]
What is the expected correct behavior?
Instead of 401 - the package should deploy
Relevant logs and/or screenshots
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.142 s
[INFO] Finished at: 2020-05-13T16:56:00+00:00
[INFO] Final Memory: 15M/56M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy-file (default-cli) on project mule-4-template-project-F2: Failed to deploy artifacts: Could not transfer artifact 0dd19ae0743567:xxxxx-project-F2:jar:1.0.3 from/to gitlab-maven (https://gitlab.com/api/v4/projects/xxxxx/packages/maven): Unauthorized (401) -> [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
Output of checks
Happens on GitLab.com
Edited by sameer shaik