2

I am trying out GitHub packages beta, i have a maven project which i want to publish. In the POM.xml i did add below tag. test-package is my repository name.

    <repository>
        <id>github</id>
        <name>GitHub amarkum Apache Maven Packages</name>
        <url>https://maven.pkg.github.com/amarkum/test-package</url>
    </repository>
</distributionManagement>

I have properly configured access token in my ~/.m2/setting.xml.

When i run mvn deploy command it's not able to publish the package. I tried with manually providing the token as well

mvn deploy -Dregistry=https://maven.pkg.github.com/amarkum -Dtoken=<MY_TOKEN_GENERATED>.

The token i generated has all the privileges to be sure, apart from read:packages and write:packages scopes

Error

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy) on project test-package: Failed to retrieve remote metadata com.codefolx.test:test-package:1.0-SNAPSHOT/maven-metadata.xml: Could not transfer metadata com.codefolx.test:test-package:1.0-SNAPSHOT/maven-metadata.xml from/to github (https://maven.pkg.github.com/amarkum/test-package): Not authorized , ReasonPhrase:Unauthorized. -> [Help 1]

where am i going wrong?

Amar Kumar
  • 31
  • 8
  • [I think this answer should be work for you](https://stackoverflow.com/a/63862342/5549569) – Liam Sep 12 '20 at 16:16

2 Answers2

1

The problem occurred with me because I configured the section (.m2/settings.xml) with a wrong server name. I've written the name with a letter more. When I fixed the serve name, it uploaded the file correctly.

Felipe Desiderati
  • 2,414
  • 3
  • 24
  • 42
0

So I think the reason you are seeing this is because you've missed the step of adding the github profile to your maven settings: https://help.github.com/en/articles/configuring-apache-maven-for-use-with-github-package-registry#authenticating-to-github-package-registry

Also even when you've done this i still sometimes see and error about the maven-metadata.xml files failing to upload, but the package is still published

  • I did add it as mentioned in the description. I have properly configured access token in my ~/.m2/setting.xml. – Amar Kumar Oct 07 '19 at 18:24
  • @AmarKumar are you using any plugins for deployment within your pom? I've found that these sometimes can cause the git deployments to fail. Usually mine just work with just adding the maven-compiler-plugin – Dave Storey Oct 08 '19 at 12:16
  • Logged a support ticket to GitHub, it has been escalated. Hey there Amar, I've been seeing that there are some issues with SNAPSHOTs as a whole at present, we don't support mutating packages in terms of publishing a new SNAPSHOT to override an existing SNAPSHOT, however I'm also seeing issues with SNAPSHOT versions and installations - I'm going to escalate this over to our engineering team, and add a +1 against the internal tasks we have for SNAPSHOTs. I'll let you know when I have an update that I can share here. Can you try using semver versioning and let me know how you get on? – Amar Kumar Oct 12 '19 at 04:31