问题描述
我正在建立一个项目。
此项目应使用我的parent.pom中的Github registry。
即使我从.m2存储库中删除了父pom,它也可以在我的机器上正常运行
不幸的是,每次按下后我总会得到一个error when Github tries to run the tests,因为无法解决父pom。
[ERROR] Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM for io.joergi:basics:0.0.1-SNAPSHOT: Could not
transfer artifact io.joergi:parent-jdk11-mongo:pom:2.3.0-1.RELEASE from/to github
(https://maven.pkg.github.com/joergi/parent-jdk11-mongo): Transfer Failed for
https://maven.pkg.github.com/joergi/parent-jdk11-mongo/io/joergi/parent-jdk11-
mongo/2.3.0-1.RELEASE/parent-jdk11-mongo-2.3.0-1.RELEASE.pom 400 Bad Request and
'parent.relativePath' points at wrong local POM @ line 5,column 10
@
父pom具有以下定义:
<groupId>io.joergi</groupId>
<artifactId>parent-jdk11-mongo</artifactId>
<version>2.3.0-1.RELEASE</version>
<packaging>pom</packaging>
<name>joergi.io parent-jdk11-mongo</name>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.3.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
我的new project使用Github操作进行自动测试。
它像这样集成了父pom:
<parent>
<groupId>io.joergi</groupId>
<artifactId>parent-jdk11-mongo</artifactId>
<version>2.3.0-1.RELEASE</version>
</parent>
<distributionManagement>
<repository>
<id>github</id>
<name>GitHub joergi Apache Maven Packages</name>
<url>https://maven.pkg.github.com/joergi/parent-jdk11-mongo</url>
</repository>
</distributionManagement>
我在新项目中也有一个settings.xml
<activeProfiles>
<activeProfile>github</activeProfile>
</activeProfiles>
<profiles>
<profile>
<id>github</id>
<repositories>
<repository>
<id>github</id>
<name>GitHub joergi Apache Maven Packages</name>
<url>https://maven.pkg.github.com/joergi/parent-jdk11-mongo</url>
</repository>
</repositories>
</profile>
</profiles>
<servers>
<server>
<id>github</id>
<username>joergi</username>
<password>${{ secrets.PACKAGES_READ_ONLY }}</password>
</server>
</servers>
秘密在我的Github秘密中。如果我删除或更改它,那么我不再获得授权,因此可以正常工作。
解决方法
因此,在github community user brightran的帮助下,我可以对其进行修复,请参见post for more information。
以某种方式,settings.xml中的秘密密码无法正常工作,这就是为什么我建议采用另一种方式。
在maven部署脚本中,我设置了一个环境变量,如下所示:
- name: Publish to GitHub Packages
run: mvn deploy -s settings.xml
env:
MVN_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
以及在settings.xml中,我读取了变量,如您在此处看到的。
<settings . . .>
. . .
<servers>
<server>
<id>github</id>
<username>USERNAME</username>
<password>${MVN_AUTH_TOKEN}</password>
</server>
</servers>
</settings>
现在可以正常使用了。