registrypom.xmlgithub-actionsparent-pom

works locally, fails on Github Actions: can't transfer Github hosted parent pom, receives Bad Request an parent.relativePath points at wrong local POM


I'm at the moment building a project.
This project should use my parent.pom from the Github registry.

It works perfectly on my machine, even if I delete the parent-pom from my .m2 repository
Unfortunately, I always get an error when Github tries to run the tests after each push, because the parent-pom can't be resolved.

[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
     @ 

The parent-pom has this definition:

<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>

My new project use Github actions for automatic testing.
It integrates the parent pom like this:

<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>

I also have a settings.xml in the new project

  <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>

The secret is in my Github secrets. If I remove or change it, I'm not authorized anymore, so this works.

Can one of you give me a hint, what is wrong


Solution

  • So, with the help of github community user brightran I was able to fix it, see the post for more information.

    Somehow the password from the secrets in the settings.xml was not working, that why I go another way, as suggested.

    in the maven deployment script I set a environment variable as you can see here:

    - name: Publish to GitHub Packages
      run: mvn deploy -s settings.xml
      env:
        MVN_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    

    and in the settings.xml I read the variable, as you can see here.

    <settings . . .>
      . . .
      <servers>
        <server>
          <id>github</id>
          <username>USERNAME</username>
          <password>${MVN_AUTH_TOKEN}</password>
        </server>
      </servers>
    </settings>
    

    this works now as expected.