Suppressing GPG signing for Maven-based continuous integration builds (Travis CI)(禁止基于 Maven 的持续集成构建的 GPG 签名 (Travis CI))
问题描述
我正在使用 Travis-CI 为一些 Java 开源项目提供持续集成构建.我正在努力.
I'm using Travis-CI to provide continuous integration builds for a few Java open source projects I'm working on.
通常这很顺利,但是当 POM 指定 GPG 签名时我遇到了问题,例如
Normally this works smoothly, but I have a problem when the POM specifies GPG signing, e.g.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
这会导致 Travis 构建失败 - 显然是因为它在运行 mvn install 时没有可用的密码.有关示例,请参阅 此构建.
This causes the Travis build to fail - apparently because it does not have a passphrase available while running mvn install. See this build for an example.
配置 Maven 和/或 Travis 以跳过 CI 测试构建的 GPG 签名,但在我执行正确的发布构建时仍执行 GPG 签名的最佳方法是什么?
What is the best way to configure Maven and/or Travis to skip GPG signing for CI test builds, but still perform GPG signing when I do a proper release build?
推荐答案
你需要创建一个profile &确保仅在进行发布构建时才运行它.
You need to create a profile & make sure you run that only when you do the release build.
删除当前插件,并将其添加到配置文件中,如下所示:
Remove the current plugin, and add it in a profile like this:
<profiles>
<profile>
<id>release-sign-artifacts</id>
<activation>
<property>
<name>performRelease</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
然后当你真正需要发布时,将属性添加到你的 mvn 命令中:
And then when you actually need to do a release, add the property to your mvn command:
mvn -DperformRelease=true ...
这篇关于禁止基于 Maven 的持续集成构建的 GPG 签名 (Travis CI)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:禁止基于 Maven 的持续集成构建的 GPG 签名 (Travi
基础教程推荐
- RabbitMQ:消息保持“未确认"; 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- Struts2 URL 无法访问 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
