问题
I'm trying to use Github's new Actions CI server to deploy packages to Github's new packages feature. It's not going well.
I think it's all set up correctly, but I get this error:
Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy 
(default-deploy) on project myproject: Failed to deploy artifacts: Could not 
find artifact com.mycompany:myproject:pom:1.5 in github 
(https://maven.pkg.github.com/mycompany/mycompany_repository) -> [Help 1]
This happens after it appears to upload that same pom successfully:
Uploading to github: https://maven.pkg.github.com/mycompany/mycompany_repository
/com/mycompany/myproject/1.5/myproject-1.5.pom
Progress (1): myproject-1.5.pom (4.1/6.1 kB)
Progress (1): myproject-1.5.pom (6.1 kB)
So, it looks to me like it is successfully uploading the pom, but then it fails to download the same pom a few seconds later.
I'm running the deploy with debug switches on: mvn -X -e deploy, but I can't see the exact http commands that Maven is sending to the server.
How do I debug this? Is there some Maven/Aether transport or something that will log what is going on under the covers?
回答1:
You can enable debug logging in the workflows.
Just add the secret:
ACTIONS_RUNNER_DEBUG
And set to true
See a similar answer here
回答2:
In case anyone else lands here looking for a solution to OPs issue publishing to github, I had a similar issue and found that the URLs needed in settings.xml and pom.xml are inconsistent. In your settings.xml, the repo URL needs to be of the form https://maven.pkg.github.com/myuser/com/mycompany/mypackage, whereas in your project's pom file, it needs to be of the form https://maven.pkg.github.com/myuser/mypackage. So, for example, your settings.xml file in ~/.m2 would look something like this:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <activeProfiles>
    <activeProfile>github</activeProfile>
  </activeProfiles>
  <profiles>
    <profile>
      <id>github</id>
      <repositories>
        <repository>
          <id>central</id>
          <url>https://repo1.maven.org/maven2</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>false</enabled></snapshots>
        </repository>
        <repository>
          <id>github</id>
          <name>GitHub Apache Maven Packages</name>
          <url>https://maven.pkg.github.com/myuser/com/mycompany/mypackage</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>false</enabled></snapshots>
        </repository>
      </repositories>
    </profile>
  </profiles>
  <servers>
    <server>
      <id>github</id>
      <username>myuser</username>
      <password>mypersonalaccesstoken</password>
    </server>
  </servers>
</settings>
Whereas the pom.xml file in the root of your project would need to look like this:
<project>
  ...
  <groupId>org.mycompany</groupId>
  <artifactId>mypackage</artifactId>
  <version>1.0.0</version>
  ...
  <distributionManagement>
    <repository>
      <id>github</id>
      <name>GitHub Apache Maven Packages</name>
      <url>https://maven.pkg.github.com/myuser/mypackage</url>
    </repository>
  </distributionManagement>
  ...
</project>
Other than this minor (but crucial) detail, my steps were the same as those outlined here. This allowed me to publish my Maven package to github package registry.
回答3:
The following solution works for me:
- Create a repository for packages e.g. 
maven-packages - Add 
<server></server>settings under<servers>insettings.xml: (do this per id used below) 
    <server>
        <id>github<id/>
        <username>YOUR GITHUB USERNAME</username>
        <password>A GITHUB TOKEN YOU CREATE FOR PUBLISHING PACKAGES</password>
    </server>
- Do NOT add 
<activeProfiles>,<profile>or<repositories>tosettings.xml(only add<server>elements) as this is redundant for publishing and I am adding them to consuming projects'maven.xmlso no need for duplication. - Add repository/ies to 
distributionManagementinpom.xmlas follows: 
    <distributionManagement>
        <snapshotRepository>
            <id>github-snapshot</id>
            <name>GitHub snapshot</name>
            <url>https://maven.pkg.github.com/OWNER/maven-packages/</url>
            <uniqueVersion>true</uniqueVersion>
        </snapshotRepository>
        <repository>
            <id>github-release</id>
            <name>GitHub release</name>
            <url>https://maven.pkg.github.com/OWNER/maven-packages/</url>
            <uniqueVersion>false</uniqueVersion>
        </repository>
    </distributionManagement>
Where OWNER is the GitHub account your project is / projects are under and maven-packages is the repositories you want to publish you project(s) to.
This enables using a dedicated repository for listing packages instead of publishing each project's package to a different (its own) repository, making consumption of multiple packages from your GitHub account easier, as you only need to configure a single repository for these packages:
    <repositories>
        <repository>
            <id>github</id>
            <name>GitHub</name>
            <url>https://maven.pkg.github.com/OWNER/maven-packages/</url>
        </repository>
    </repositories>
Note: in the <servers> section of your settings.xml define a <server> per id used in repositories and distributionManagement e.g. github-snapshot, github-release, github in the above examples.
来源:https://stackoverflow.com/questions/59414112/how-to-see-what-maven-is-sending-to-a-server-during-deploy