Use of signing plugin with GPG agent fails with Gradle >= 5.x

Hi folks,

After some previous help getting publishing and signing working with Gradle 4.8, I’ve been happy with the results over the last two years. However, I have struggled getting the signing to work with more recent Gradle releases (5 and later). I’ve tried to follow the upgrade guidance and current documentation, but I’ve been unsuccessful in getting signing to work.

I did see a bug report GitHub issue #8657, but this was closed. However, I do wonder if that closure was correct; I think it’s possible there is an unfixed bug here.

My conversion to Gradle 7.6 may be found on this branch. As shown on this line, this is how my signing is set up:

signing {
    required { isReleaseVersion }
    sign publishing.publications.mavenJava

tasks.withType(Sign) {
    onlyIf { isReleaseVersion && project.hasProperty('signing.keyId') }

task publishSnapshot(dependsOn: publish) {
    if (isReleaseVersion) {
        enabled = false
        dependsOn = []

This is generic for all three of the subprojects. When I run “./gradlew publish”, I get:

> Task :ome-model-doc:signMavenJavaPublication FAILED

FAILURE: Build failed with an exception.

* What went wrong:
A problem was found with the configuration of task ':ome-model-doc:signMavenJavaPublication' (type 'Sign').
> No value has been specified for property 'signatory.keyId'.

(Note: to reproduce, edit VERSION and remove “-SNAPSHOT” to enable signing; you might also need “-Ppython=python3” and sphinx-build on the path.)

The error is exactly the same as in the GitHub issue #8657.

Locally, I have my user ~.gradle/ with the properties “signing.keyId”, “ossrhUsername” and “ossrhPassword” for signing and uploading to Maven Central. These were sufficient with Gradle 4.8.

If anyone has any suggestions for how to update my build to work correctly with Gradle 6.7, I would be very grateful. Alternatively, if I’ve hit a bug, it would be great if anyone would confirm this is a problem, and if possible, suggest a workaround.

If I’m doing anything outdated which I’ve not already picked up while updating to Gradle 6.7, then any pointers for things I should be doing the “new way” would also be much appreciated.

Kind regards,

To answer my own question, I found that others are setting the property “signing.gnupg.keyName”. This is in the documentation, but it’s not clear to me why this isn’t defaulting to “signing.keyId” since this always worked before. I’m not sure under which circumstances there would be a reasonable need for them to differ. I’m not sure why “useGpgCmd()” would not simply use the default configuration and be directly substitutable for the default signatory.