禁止基于Maven的持续集成构建的GPG签名(Travis CI) [英] Suppressing GPG signing for Maven-based continuous integration builds (Travis CI)

查看:233
本文介绍了禁止基于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构建失败 - 显然是因为它在运行<$时没有可用的密码c $ c> 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?

推荐答案

您需要创建个人资料&确保只在进行发布版本时才运行。

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)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆