如何查看在部署期间Maven向服务器发送的内容?

我正在尝试使用Github的新actions CI服务器将程序包部署到Github的新程序包功能。情况不妙。

我认为所有设置都正确,但出现此错误:

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]

发生这种情况之后似乎成功上传了同一pom:

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)

所以,在我看来,它成功上传了pom,但是几秒钟后却无法下载相同的pom。

我正在使用以下调试开关运行部署:mvn -X -e deploy,但是我看不到Maven发送到服务器的确切http命令。

我该如何调试?是否有一些Maven / Aether传输或一些可以记录下幕后情况的东西?

zhuhailucye 回答:如何查看在部署期间Maven向服务器发送的内容?

如果有人在这里寻找OP发布到github的问题的解决方案,我也遇到了类似的问题,发现settings.xml和pom.xml中所需的URL不一致。在settings.xml中,回购URL的格式应为 https://maven.pkg.github.com/myuser/com/mycompany/mypackage ,而在项目的pom文件中,其格式应为 https://maven.pkg.github.com/myuser/mypackage 。因此,例如,〜/ .m2中的settings.xml文件如下所示:

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

项目根目录中的pom.xml文件应如下所示:

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

除了这个次要(但很关键)的细节之外,我的步骤与here中概述的步骤相同。这使我可以将Maven软件包发布到github软件包注册表中。

,

您可以在工作流程中启用debug logging

只需添加秘密:

ACTIONS_RUNNER_DEBUG

并设置为true

看到类似的答案here

,

以下解决方案对我有用:

  1. 为软件包创建存储库,例如maven-packages
  2. <server></server>的{​​{1}}下添加<servers>设置:(按下面使用的ID执行此操作)
settings.xml
  1. 不要 <server> <id>github<id/> <username>YOUR GITHUB USERNAME</username> <password>A GITHUB TOKEN YOU CREATE FOR PUBLISHING PACKAGES</password> </server> <activeProfiles><profile>添加到<repositories>仅添加settings.xml元素),因为这对于发布是多余的,我将它们添加到使用项目的<server>中,因此无需重复。
  2. 如下所示将存储库添加到maven.xml中的distributionManagement
pom.xml

其中 <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> 是您的项目所在的GitHub帐户/项目所在的项目,而OWNER是您要将项目发布到的存储库。

这使您可以使用专用的存储库来列出软件包,而不是将每个项目的软件包发布到不同的(自己的)存储库中,从而使从GitHub帐户使用多个软件包变得更加容易,因为您只需为这些软件包配置一个存储库:

maven-packages

注意:在 <repositories> <repository> <id>github</id> <name>GitHub</name> <url>https://maven.pkg.github.com/OWNER/maven-packages/</url> </repository> </repositories> 的{​​{1}}部分,为<servers>settings.xml中使用的<server>定义一个id。以上示例中的repositoriesdistributionManagementgithub-snapshot

,

我只花了3个小时来调试为什么该页面上的指南对我不起作用。如果您遵循此处发布的指南1

OWNER是您的github用户名,REPOSITORY是-您猜对了,就是存储库名称。

只记得在OWNER和REPOSITORY中都使用小写字母。

,

生成个人访问令牌时,请确保令牌的作用域是 repo:* 作用域以及更明显的 write:packages 和 read:packages 作用域(不要禁用 repo 作用域)

否则就那样

本文链接:https://www.f2er.com/2890284.html

大家都在问