sbt-ci-release icon indicating copy to clipboard operation
sbt-ci-release copied to clipboard

Cryptic error message when having multiple gpg keys

Open ghostbuster91 opened this issue 2 years ago • 1 comments

If user has multiple keys and the imported one isn't the default one (which is often the case in my opinion) the signing process will failed with not very helpful message:

[info] gpg: signing failed: Bad passphrase
[info] gpg: signing failed: Bad passphrase
[error] stack trace is suppressed; run last rules2_11 / signedArtifacts for the full output
[error] (rules2_11 / signedArtifacts) Failure running 'gpg --batch --pinentry-mode loopback --passphrase ... --detach-sign --armor --use-agent --output /home/kghost/workspace/scalafix-unified/rules/target/jvm-2.11/unified_2.11-0.0.2+3-29124f7a+20220206-1145-SNAPSHOT.pom.asc /home/kghost/workspace/scalafix-unified/rules/target/jvm-2.11/unified_2.11-0.0.2+3-29124f7a+20220206-1145-SNAPSHOT.pom'.  Exit code: 2
[error] Total time: 5 s, completed Feb 6, 2022, 11:45:06 AM

After carefully inspecting the gpg command we might notice that there is no information about which key to use.

sbt-pgp exposes usePgpKeyHex method to explicitly set key which will be used to perform operations. https://github.com/sbt/sbt-pgp#configuration-signing-key

I think that it should be possible to obtain key_id during the process and set it somewhere among the lines: https://github.com/sbt/sbt-ci-release/blob/main/plugin/src/main/scala/com/geirsson/CiReleasePlugin.scala#L143

Otherwise, please consider adding some note to the readme with the link to relevant section in the sbt-pgp.

ghostbuster91 avatar Feb 06 '22 12:02 ghostbuster91