maven - 在哪里保存 Windows 上运行的 Jenkins 的 GPG key ?

标签 maven jenkins

我正在尝试使用 Jenkins 将我的 Artifact 发布到 OSS Sonatype Nexus 服务器。但是当尝试对 Artifact 进行签名时,我收到以下错误。我已经生成了 gpg key ,并将其放在 Windows 计算机上的 C:/Users/Sara/AppData/Roaming/gnupg 文件夹下。来自另一个问题Where to keep a GPG secret key for a Maven project in CI environment? ,我可以看到答案是针对基于 Unix 的环境。任何人都可以阐明在 Windows 环境中将 jenkins 的 key 放置在哪里吗?

[INFO] --- maven-gpg-plugin:1.1:sign (sign-artifacts) @ StudentEnrollmentWithREST ---
    gpg: no default secret key: secret key not available
    gpg: signing failed: secret key not available
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 1:27.647s
    [INFO] Finished at: Mon Jan 20 12:12:27 CST 2014
    [INFO] Final Memory: 22M/53M
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-gpg-plugin:1.1:sign (sign-artifacts) on project StudentEnrollmentWithREST: Exit code: 2 -> [Help 1]
    [ERROR] 
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR] 
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1:45.118s
[INFO] Finished at: Mon Jan 20 12:12:33 CST 2014
[INFO] Final Memory: 8M/19M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.1:prepare (default-cli) on project StudentEnrollmentWithREST: Maven execution failed, exit code: '1' -> [Help 1]
[JENKINS] Archiving C:\Program Files (x86)\Jenkins\workspace\Upload REST Release Artifacts\pom.xml to com.github.elizabetht/StudentEnrollmentWithREST/1.3-SNAPSHOT/StudentEnrollmentWithREST-1.3-SNAPSHOT.pom
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
channel stopped
Skipping Cobertura coverage report as build was not UNSTABLE or better ...
Finished: FAILURE

最佳答案

根据gpg:sign文档。
默认为 ~/.gnupg%APPDATA%/gnupg${gpg.homedir} 应该可以在您的文件夹中找到您的 key 环目前已描述。 还可以配置默认名为 pubring.gpgsecring.gpg 的文件。

也许问题在于找到正确的 key ,maven 使用“默认 key ”,除非另有配置。 key 环中的第一个 key 是默认 key 。

选择一个 key - 这可能会出现在项目/父级或设置中,甚至可能出现在命令行中

<properties>
    <gpg.keyname>C78F3CC4</gpg.keyname>
</properties>

其他一些配置更有可能是“每个主机”,可能是您的 settings.xml 中的配置文件

<profile>
    <id>gpg-release</id>
    <properties>
        <gpg.passphrase>...</gpg.passphrase>
        <gpg.useagent>true</gpg.useagent>
<!--
        <gpg.defaultKeyring>false</gpg.defaultKeyring>
        <gpg.homedir>/private/.../.gnupg</gpg.homedir>
        <gpg.publicKeyring>/private/.../.gnupg/pubring.gpg</gpg.publicKeyring>
        <gpg.secretKeyring>/private/.../.gnupg/secring.gpg</gpg.secretKeyring>
-->
    </properties>
</profile>

如果您使用 OSS Sonatype 的命令行而不是在设置 xml 中,那么它将需要进一步的练习。
来自 OSS Sonatype documentation .
因为 maven-release-plugin 将启动一个新的 Maven 实例,所以 -Dgpg.passphrase=PASSPHRASE 在这种情况下不起作用,您应该使用 mvn release:perform -Darguments=-Dgpg.passphrase=PASSPHRASE 【并在项目pom中配置${arguments}的用法】

关于maven - 在哪里保存 Windows 上运行的 Jenkins 的 GPG key ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21241439/

相关文章:

jenkins - 将数组和 ArrayList 追加到 ArrayList

linux - Jenkins 执行 bash shell 命令

java - Spring事务性包私有(private)方法

eclipse - Maven Eclipse Autobuilder 继续构建,即使没有任何改变

Windows 10 杀死 EDB Postgres 8080 服务器

continuous-integration - 在jenkins构建结果页面中显示工件

jenkins - 从与当前管道源相同的分支加载 Jenkins 共享库

java - Spring Boot Devtools 无法与 Tomcat Embed Jasper 配合使用

java - 需要在 AspectJ 项目中配置 Spring AOP Advice

java - 将 Maven 项目及其依赖项添加到我的 Eclipse 项目中,最佳工作流程