我正在使用 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)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!