Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 2
Message 1 of 19

GitHub package registry as Maven repo - trouble uploading artifact

Hi,

 

I have followed the guide on https://help.github.com/en/articles/configuring-apache-maven-for-use-with-github-package-registry

I create a dedicated machine user and created an access token with scopes "read:packages", "write:packages" and "repo" and configured my maven settings XML accordingly, as the guide describes.

 

When I do a mvn deploy it just gives me a 400 bad request error back:

org.apache.maven.wagon.TransferFailedException: Failed to transfer file: https://maven.pkg.github.com/myorganisation/my-repo/com/orgname/appname/sample-integration/1.0-SNAPS.... Return code is: 400, ReasonPhrase: Bad Request.

I wish it could be a little more verbose and reveal what part of the request that is invalid.

 

I don't know how to troubleshoot this further, so I'm hoping that someone here has experienced the same issue and found a solution or someone that can give me hint on how to troubleshoot in a good way. Running mvn in debug mode didn't give any helpful information either.

18 Replies
Community Manager
Message 2 of 19

Re: GitHub package registry as Maven repo - trouble uploading artifact

Hi @hyst-andreas,

 

Thank you for being here! 

 

Do your XML files have an XML declaration? If not, please add this to the top of your XML files and try again:

<?xml version="1.0" encoding="UTF-8"?>

 


Best,
AndreaG

Mark helpful posts with Accept as Solution to help other users locate important info. Don't forget to give Kudos for great content!

Copilot Lvl 2
Message 3 of 19

Re: GitHub package registry as Maven repo - trouble uploading artifact

I'm also seeing a 400 like this with the XML declaration present while publishing with gradle.

 

Are there additional required elements in the POM?

Copilot Lvl 2
Message 4 of 19

Re: GitHub package registry as Maven repo - trouble uploading artifact

Hi, @hyst-andreas 

 

I'm at the exact same place. Obvious its something wrong, but I even got some packages pushet to my repo. I have no clue what actually is failing. The error message is the same what every I do...

 

It would be sweet to push our private packages to Github, do you have any more success on this issue?

 

mvh. Michael

Copilot Lvl 2
Message 5 of 19

Re: GitHub package registry as Maven repo - trouble uploading artifact

Hi @mijohansen 

 

We ended up setting up our private repo in Google Cloud instead and we will stick to this at least for now. I hope you'll found a solution to the problem

 

Best regards,

Andreas

Ground Controller Lvl 1
Message 6 of 19

Re: GitHub package registry as Maven repo - trouble uploading artifact

I have this same issue. Can't figure out what is wrong.

Copilot Lvl 2
Message 7 of 19

Re: GitHub package registry as Maven repo - trouble uploading artifact

Hello!

 

We're looking into this error.  If you could email support at github.com with more details of your logs that include your organization and repository we could look further into the specifics. 

 

Is this related to a SNAPSHOT? Or general publishing?

 

Thanks,

~ Bryan

Copilot Lvl 2
Message 8 of 19

Re: GitHub package registry as Maven repo - trouble uploading artifact

Thank you, Clark!

 

We have opened another ticket on user @frode-carlsen. To avoid duplicate work on your part. We have also tried several different configurations, but Carlsen have more information about that too.

 

Michael

Copilot Lvl 3
Message 9 of 19

Re: GitHub package registry as Maven repo - trouble uploading artifact

Got it somewhat working.

 

In addition to the guidelines provided here

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

I had to do the following (on a private repo)

1. Since I was using the GITHUB_TOKEN then username had to be "x-access-token" in the settings.xml

2. Sources jars fails to upload with 400. Not sure if this applies to all jars with classifiers.  But it should be possible to upload javadoc and sources as well for the GPR to be fully useful, so I assume it's a bug(?)

3. The checksum files fail to upload (maven gives a warning but seems to be another 400 issue)

Copilot Lvl 3
Message 10 of 19

Re: GitHub package registry as Maven repo - trouble uploading artifact

Further on to this - we did manage to upload multiple jars and poms, but only by 'brute-forcing' using the mvn deploy:deploy-file on every artifact (instead of mvn deploy). 

 

So GPR must be sending something back that the maven (wagon) deployer does not interpret as expected for subsequent uploads (a cookie or time-limited token)?  But since the maven code is 5+ years old, I'm guessing the problem lies with the Github package registry not supporting reuse of connections or sessions on subsequent calls, as the alternative is to patch the maven code. Or perhaps the Github Action could have a better uploader included for maven (could potentially be faster as well).