我正在尝试将我的工件作为打包的Github包进行部署。在干净的部署中,我得到了
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project cardgame: Failed to deploy artifacts: Could not transfer artifact org.moderatelycomfortablechair:cardgame:jar:0.0.1-20201222.145834-1 from/to github (https://maven.pkg.github.com/ModeratelyComfortableChair/CardGame): Access denied to https://maven.pkg.github.com/ModeratelyComfortableChair/CardGame/org/moderatelycomfortablechair/cardgame/0.0.1-SNAPSHOT/cardgame-0.0.1-20201222.145834-1.jar. Error code 403, Forbidden -> [Help 1]我的pom.xml包含以下内容
<modelVersion>4.0.0</modelVersion>
<groupId>org.moderatelycomfortablechair</groupId>
<artifactId>cardgame</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>cardgame</name>..。
<distributionManagement>
<repository>
<id>github</id>
<name>GitHub ModeratelyComfortableChair Apache Maven Packages</name>
<url>https://maven.pkg.github.com/ModeratelyComfortableChair/CardGame</url>
</repository>我的~/.m2/settings.xml与here相同,其中用户名和所有者是ModeratelyComfortableChair (我的github用户名),密码是具有repo和读写访问权限的个人访问令牌。
发布于 2021-04-19 20:48:13
首先,您需要在您的个人访问令牌(PAT)上拥有read:write access to packages。这应该可以解决你的问题。
这与您的私有存储库工作得非常好。但是,对于那些使用组织存储库并实施了单点登录( Single Sign-On,SSO)的人来说,这可能是不够的。必须显式授权令牌进行SSO。而Maven命令不会对此进行提示。
有不同的方法来授权令牌,其中两种方法如下所述。

克隆存储库
git clone https://[USERNAME]:[TOKEN]@[GIT_ENTERPRISE_DOMAIN]/[ORGANIZATION]/[REPO].git
它将抛出一个错误,并为您提供一个用于使用SSO授权令牌的URL。在浏览器中访问URL并授权给定令牌的SSO。授权后,您应该能够发布/部署您的工件。

干杯!
https://stackoverflow.com/questions/65411027
复制相似问题