微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Maven 将工件部署到 nexus 存储库失败,gpg 密钥丢失错误

如何解决Maven 将工件部署到 nexus 存储库失败,gpg 密钥丢失错误

我正在尝试将我的本地工件部署到 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. 我已经使用 .asc

    导入了 gpg --import file.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?

解决方法

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

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

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。