Suppressing GPG signing for Maven-based continuous integration builds (Travis CI)

mikera :

I'm using Travis-CI to provide continuous integration builds for a few Java open source projects I'm working on.

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>

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.

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?

Peter :

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>

And then when you actually need to do a release, add the property to your mvn command:

mvn -DperformRelease=true ...

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Continuous integration (CI) with Phabricator?

Travis-CI builds on schedule

restarting builds with travis ci api

Cache Brew builds with travis ci

Error with integration in Travis-CI

Signing generated artifacts on Travis-CI

Continuous Deployment Using Travis CI and Docker

Build dependencies and local builds with continuous integration

What does "builds" mean in Continuous Integration?

Continuous Integration with Talend and Jenkins/Maven

How to Codeception and Gitlab CI (Continuous Integration)

Use xcodebuild (Xcode 8) and automatic signing in CI (Travis/Jenkins) environments

How to GPG sign a file that is built by Travis-CI

"gpg: signing failed: Inappropriate ioctl for device" on MacOS with Maven

Sonarcloud is not authorized using Travis CI and Maven

Usage of environment variable of Travis CI in maven test

Deploying a Maven version to Github using Travis CI

Travis CI ignoring MAVEN_OPTS?

What is a good workflow for Continuous Deployment to a VPS using Travis CI and Capistrano?

Travis CI creates two builds for each Github commit push

Travis-CI: how to cache composer executable between builds?

Travis CI builds app but doesn't deploy to Surge.sh

Travis-CI only deploy once after all builds finish

How does travis-ci.org throttle builds?

Travis CI works correctly, but Coveralls doesn't see the builds

Project builds on local but fails in travis-ci container

Problems doing Travis-CI builds with new Flutter project

Testing matplotlib-based plots in Travis CI

Signing an existing commit with GPG