英文:
Cannot deploy to GitHub Packages with Maven
问题
按照这个指南,我创建了一个非常简单的GitHub Repo并尝试部署到GitHub Packages。
然而,我不断地、随机地遇到以下错误之一:
- 无法部署构件:无法传输 com.sadriu:packaging:pom:1.0.0 的构件至 github (https://maven.pkg.github.com/sadrian/packaging):maven.pkg.github.com:443 未响应
- 无法部署构件:无法传输 com.sadriu:packaging:pom:1.0.0 的构件至 github (https://maven.pkg.github.com/sadrian/packaging):状态码:400,原因短语:Bad Request (400)
有趣的是,部署快照(SNAPSHOTS)的操作正常工作!
我已经尝试过:
- 不同的Java版本(8和11)
- 不同的maven-deploy-plugin版本
在设置了我的个人访问令牌(PAT)在我的 .m2/settings.xml 后,我还在本地尝试过。
我还尝试直接PUT POM 或/和 JAR,并且它是有效的:
curl -X PUT \
"https://maven.pkg.github.com/sadrian/packaging/com/sadriu/packaging/1.0.0/packaging-1.0.0.jar" \
-H "Authorization: token ***" \
--upload-file "<<PATH_TO_JAR>>" -vvv
curl -X PUT \
"https://maven.pkg.github.com/sadrian/packaging/com/sadriu/packaging/1.0.0/packaging-1.0.0.pom" \
-H "Authorization: token ***" \
--upload-file "<<PATH_TO_POM>>" -vvv
响应:
...
* We are completely uploaded and fine
< HTTP/2 200
< access-control-allow-methods: OPTIONS, PUT
< access-control-allow-origin: *
< content-security-policy: default-src 'none';
< server: GitHub Registry
< strict-transport-security: max-age=31536000;
< x-content-type-options: nosniff
< x-frame-options: DENY
< x-xss-protection: 1; mode=block
< date: Fri, 03 Mar 2023 12:59:48 GMT
< content-length: 66
< content-type: text/plain; charset=utf-8
< x-github-request-id: CE82:12C8F:16396B:171471:6401EF43
<
Successfully registered maven upload: packaging-1.0.0.pom (1.0.0)
* Connection #0 to host maven.pkg.github.com left intact
有没有人知道我哪里做错了呢?
英文:
Following this guide, I created a very simple GitHub Repo and tried to deploy to GitHub Packages.
However I'm getting continuously and randomly one of the following errors:
- Failed to deploy artifacts: Could not transfer artifact com.sadriu:packaging:pom:1.0.0 from/to github (https://maven.pkg.github.com/sadrian/packaging): maven.pkg.github.com:443 failed to respond
- Failed to deploy artifacts: Could not transfer artifact com.sadriu:packaging:pom:1.0.0 from/to github (https://maven.pkg.github.com/sadrian/packaging): status code: 400, reason phrase: Bad Request (400)
Interestingly enough is the fact the deploying SNAPSHOTS works as expected!
I already tried:
- different Java versions (8 and 11)
- different maven-deploy-plugin versions
Tried out also locally, after setting my PAT in my .m2/settings.xml.
I also tried to PUT directly the POM or/and JAR and it works:
curl -X PUT \
"https://maven.pkg.github.com/sadrian/packaging/com/sadriu/packaging/1.0.0/packaging-1.0.0.jar" \
-H "Authorization: token ***" \
--upload-file "<<PATH_TO_JAR>>" -vvv
curl -X PUT \
"https://maven.pkg.github.com/sadrian/packaging/com/sadriu/packaging/1.0.0/packaging-1.0.0.pom" \
-H "Authorization: token ***" \
--upload-file "<<PATH_TO_POM>>" -vvv
Response:
...
* We are completely uploaded and fine
< HTTP/2 200
< access-control-allow-methods: OPTIONS, PUT
< access-control-allow-origin: *
< content-security-policy: default-src 'none';
< server: GitHub Registry
< strict-transport-security: max-age=31536000;
< x-content-type-options: nosniff
< x-frame-options: DENY
< x-xss-protection: 1; mode=block
< date: Fri, 03 Mar 2023 12:59:48 GMT
< content-length: 66
< content-type: text/plain; charset=utf-8
< x-github-request-id: CE82:12C8F:16396B:171471:6401EF43
<
Successfully registered maven upload: packaging-1.0.0.pom (1.0.0)
* Connection #0 to host maven.pkg.github.com left intact
Does anybody have an idea what am I doing wrong?
答案1
得分: 0
根据 @joshiste 的提到,问题似乎是由于 Maven 版本 >= 3.9.0 引起的。
在查看 这个链接 后,我尝试运行 mvn deploy 时加上 -Dmaven.resolver.transport=wagon,它成功了!
可能降级 Maven 也会起作用,但我还没有尝试。
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论