How do you upload a Maven artifact to Github Packages using the command line?

I am trying to upload a Maven artifact I haven’t built to one my Organization’s GitHub package registry. I am using the deploy:deploy-file Maven plugin in order to do so. Here is the command I have been using:

mvn deploy:deploy-file -Dfile=[THE JAR FILE] -Durl=[ORG] -Dregistry=[ORG] -DgroupId=[GID] -DartifactId=[ARTIFACTID] -Dversion=[VERSION] -DgeneratePom=false-Dtoken=[MY GITHUB TOKEN]

As a result I am receiving 401 errors from Github. I have made sure that:

  • I have sufficient permissions inside of my Organization (currently Owner).
  • The token i am using is valid and has the appropriated scopes: I put all of them on to test.

Also, the github package page states:

\<!-- Just a single step: Deploy using a GitHub token --\>$ mvn deploy -Dregistry=[org] -Dtoken=GH\_TOKEN

Why can’t I find any information in Maven documentation about registry or token parameters? Can I upload this file to the organization’s registry without any kind of XML configuration file, using only the cli?

Thanks in advance.


Were you able to figure out a solution? I’m having the same issue.

Thank you

Hi guys,

In my case, I set in settings.xml



mvn deploy:deploy-file -Dfile=[THE JAR FILE] -Durl=[ORG]/[REPO]-DgroupId=[GID]  
-Dpacking=jar -DartifactId=[ARTIFACTID] -Dversion=[VERSION] - **DrepositoryId=github**

I hope that works

1 Like