【问题标题】:Maven deploy artifact to nexus repository is failing with gpg key missing errorsMaven 将工件部署到 nexus 存储库失败,并出现 gpg 密钥丢失错误
【发布时间】:2021-08-30 04:45:04
【问题描述】:

我正在尝试将我的本地工件部署到 nexus 暂存存储库中,但任务失败并出现以下错误。

gpg: no default secret key: No secret key
gpg: signing failed: No secret key
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  4.886 s
[INFO] Finished at: 2021-06-14T14:12:29+05:30
[INFO] -----------------------------------------

我遵循的步骤。

  1. 我已经使用 brew 安装了 gpg
  2. gpg 版本为
      gpg (GnuPG) 2.3.1
      libgcrypt 1.9.3
    
  3. 我已将setting.xml 添加到.m2 目录路径-~/.m2/settings.xml
  4. 这是我的settings.xml file
<settings>
<servers>
 <server>
   <id>ossrh</id>
   <username>$name</username>
   <password>$password</password>
 </server>
</servers>
<profiles>
 <profile>
   <id>ossrh</id>
   <activation>
     <activeByDefault>true</activeByDefault>
   </activation>
   <properties>
     <gpg.executable>gpg</gpg.executable>
     <gpg.passphrase>$passphrase</gpg.passphrase>
   </properties>
 </profile>
</profiles>
</settings>

  1. 我已经使用gpg --import file.asc 导入了.asc 文件

  2. 当我运行gpg --list-keys 命令时,我可以看到pubuidsub 键值。

  3. 我目前的mvn版本是Apache Maven 3.6.3

  4. 我已使用以下值更新了我的项目模块 pom.xml

            <plugin>
                <groupId>org.sonatype.plugins</groupId>
                <artifactId>nexus-staging-maven-plugin</artifactId>
                <version>1.6.7</version>
                <extensions>true</extensions>
                <configuration>
                    <serverId>ossrh</serverId>
                    <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-gpg-plugin</artifactId>
                <version>1.5</version>
                <executions>
                    <execution>
                        <id>sign-artifacts</id>
                        <phase>deploy</phase>
                        <goals>
                            <goal>sign</goal>
                        </goals>
                        <configuration>
                            <!-- This is necessary for gpg to not try to use the pinentry programs -->
                            <gpgArguments>
                                <arg>--pinentry-mode</arg>
                                <arg>loopback</arg>
                            </gpgArguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>


您能否请人帮助我的配置有什么问题?为什么我收到 no default secret key: No secret key 错误?

我已经提到了这个问题,但仍然没有运气

How to deal with Gnupg error: gpg: no default secret key: No secret key gpg: [stdin]: clearsign failed: No secret key?

【问题讨论】:

  • 您是否真的启用了ossrh 个人资料?当您尝试使用 -P ossrh 时会发生什么?
  • @KarolDowbecki -P 表示什么?我应该尝试使用 mvn -P 吗?可以举个例子吗
  • mvn clean deploy -P release 我试过这个命令。我看到的仍然是同样的错误
  • 密钥无法读取的原因可能是什么?我的所有步骤都正确吗?我错过了什么吗?

标签: java maven nexus gnupg artifact


【解决方案1】:

当我尝试列出秘密时,它没有显示我的秘密gpg --list-secret

实际上,当我尝试使用gpg --list-keys 列出键时,它正在显示值。我假设 ASC 文件可以正常导入,没有任何问题。 但实际上,它没有正确导入 ASC 文件,我在导入 ASC 文件时错过了输入密码的一步。执行gpg --list-secret命令就知道了。

当您执行gpg --list-secret & gpg --list-keys 命令时,它应该显示值,然后才正确导入 ASC 文件。

【讨论】:

    猜你喜欢
    • 2015-04-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多