mik*_*era 49 java continuous-integration gnupg maven travis-ci
我正在使用Travis-CI为我正在开发的一些Java开源项目提供持续集成构建.
通常情况下这很顺利,但是当POM指定GPG签名时我遇到了问题,例如
<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>
Run Code Online (Sandbox Code Playgroud)
这导致Travis构建失败 - 显然是因为它在运行时没有可用的密码mvn install.有关示例,请参阅此构建.
配置Maven和/或Travis以跳过针对CI测试版本的GPG签名的最佳方法是什么,但是当我进行适当的版本构建时仍然执行GPG签名?
Ste*_*ner 92
通过在.travis.yml文件中添加以下行来禁用GPG签名:
install: mvn install -DskipTests -Dgpg.skip
Run Code Online (Sandbox Code Playgroud)
示例:https://github.com/stefanbirkner/system-rules/blob/master/.travis.yml
小智 26
您需要创建配置文件并确保仅在执行发布版本时运行该配置文件.
删除当前插件,并将其添加到如下配置文件中:
<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>
Run Code Online (Sandbox Code Playgroud)
然后,当您确实需要执行发布时,将该属性添加到您的mvn命令:
mvn -DperformRelease=true ...
Run Code Online (Sandbox Code Playgroud)
Der*_*erk 11
我发现使用如上所述的配置文件稍微简单一些.您可以使用gpg.passphrase属性,而不是使用新的属性值,该属性在进行签名时无论如何都需要提供.修改后的属性部分如下:
<activation>
<property>
<name>gpg.passphrase</name>
</property>
</activation>
Run Code Online (Sandbox Code Playgroud)
请注意,由于您希望在为该属性设置任何值时激活此配置文件,因此不需要任何值.
相应的命令行如下所示:
mvn <command> -Dgpg.passphrase=myverysupersecretpassphrase
Run Code Online (Sandbox Code Playgroud)
您可以通过以下两种方式运行它来测试它:
mvn install
Run Code Online (Sandbox Code Playgroud)
没有生成签名的工件,并且:
mvn install -Dgpg.passphrase=myverysupersecretpassphrase
Run Code Online (Sandbox Code Playgroud)
已创建签名工件.
要执行工件的实际签名发布,请执行以下操作:
mvn release:perform -Darguments=-Dgpg.passphrase=myverysupersecretpassphrase
Run Code Online (Sandbox Code Playgroud)
因为它不会直接传播的命令行参数的衍生进程(看到的是需要释放的行动间接http://maven.apache.org/plugins/maven-gpg-plugin/usage.html).
| 归档时间: |
|
| 查看次数: |
10069 次 |
| 最近记录: |