首页 > 解决方案 > 在 Jenkins 下运行时,maven-gpg-plugin 失败并显示“设备的 ioctl 不合适”

问题描述

当 Jenkinsmaven-gpg-plugin在远程 Linux shell 中触发时,它会以gpg: signing failed: Inappropriate ioctl for device. 直到最近,这一直有效。我不知道发生了什么变化。

我发现很多在线参考资料表明export GPG_TTY=$(tty),但这不适用于 sshtty连接null。有任何想法吗?

标签: jenkinsmaven-gpg-plugin

解决方案


我在https://myshittycode.com/2017/08/07/maven-gpg-plugin-prevent-signing-prompt-or-gpg-signing-failed-no-such-file-or-directory找到了一个很好的解释-错误/

如果页面出现故障,我将重新发布帖子的要点:

如果您 1) 最初让它在过去工作,并且 2) 尝试了来自网络的各种解决方案,但仍然无法使其工作,那么您可能已经无意识地将 GPG 版本从 2.0 升级到 2.1。

听起来很对...

为了解决这个问题,GPG 2.1 需要将 --pinentry-mode设置为loopback以获取 Maven settings.xml 中定义的 gpg.passphrase 值。

因此,将 pom.xml 中的 Maven GPG 插件配置更新为以下内容:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-gpg-plugin</artifactId>
    <version>1.6</version>
    <executions>
        <execution>
            <id>sign-artifacts</id>
            <phase>verify</phase>
            <goals>
                <goal>sign</goal>
            </goals>
            <configuration>
                <gpgArguments>
                    <arg>--pinentry-mode</arg>
                    <arg>loopback</arg>
                </gpgArguments>
            </configuration>
        </execution>
    </executions>
</plugin>

推荐阅读