rasagulla in
rasagulla in

Reputation: 31

Exception while trying to deploy Maven build JAR to github package registry

I am trying to deploy the Maven build JAR to Github Package Registry.

I am getting exception when I execute mvn deploy command.

I am using a simple Maven project which I want to create a component JAR and store in Github Package Registry.

The build is successful I now want to deploy this artifact to registry.

I have added the below in ~./m2/settings.xml.

Added a repository element under repositories in profile.

    <repository>
          <id>github</id>
          <name>GitHub OWNER Apache Maven Packages</name>
          <url>https://maven.pkg.github.com/swastikaa-in</url>
        </repository>
 <servers>
    <server>
      <id>github</id>
      <username>swastikaa</username>
      <password>my personal token from github</password>
    </server>
  </servers>        

Also, I have added the below in Maven project's pom.xml:

 <distributionManagement>
   <repository>
     <id>github</id>
     <name>GitHub OWNER Apache Maven Packages</name>
     <url>https://maven.pkg.github.com/swastikaa-in/math</url>
   </repository>
</distributionManagement>

Expected: Deployment to be successful , build artifact is deployed to Github package registry.

Actual: Exception as below:

Caused by: org.eclipse.aether.transfer.MetadataTransferException:
  Could not transfer metadata com.redjohn.tools:math:0.0.2-SNAPSHOT/maven-metadata.xml
  from/to github (https://maven.pkg.github.com/swastikaa-in/math):
  Failed to transfer file https://maven.pkg.github.com/swastikaa-in/math/com/redjohn/tools/math/0.0.2-SNAPSHOT/maven-metadata.xml
  with status code 400

Caused by: org.apache.maven.wagon.TransferFailedException:
  Failed to transfer file https://maven.pkg.github.com/swastikaa-in/math/com/redjohn/tools/math/0.0.2-SNAPSHOT/maven-metadata.xml
  with status code 400

Can someone help me in resolving the issue.

I have followed the instructions provided in the below link:

https://help.github.com/en/articles/configuring-apache-maven-for-use-with-github-package-registry

Upvotes: 1

Views: 588

Answers (2)

Muhammad Arslan Akhtar
Muhammad Arslan Akhtar

Reputation: 557

Inside your settings.xml file, <url>https://maven.pkg.github.com/OWNER/REPOSITORY</url> you need to make use that OWNER is replaced with your github username and REPOSITORY is replaced with the name of your project repository in github.

Upvotes: 1

Patricio Perpetua
Patricio Perpetua

Reputation: 11

I had the same problem and I found that snapshot versions don't work well. If you deploy a non snapshot version, it should work.

Upvotes: 1

Related Questions