在 Jenkins 下运行时,maven-gpg-plugin 因“设备的 ioctl 不合适”而失败

Gil*_*ili 6 jenkins maven-gpg-plugin

当 Jenkinsmaven-gpg-plugin在远程 Linux shell 中触发时,它会失败并显示gpg: signing failed: Inappropriate ioctl for device. 这曾经有效,直到最近。不知道有什么变化

我发现网上很多参考建议的export GPG_TTY=$(tty),但因为这并不SSH连接工作ttynull。有任何想法吗?

Gil*_*ili 16

我在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设置为环回,以获取 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>
Run Code Online (Sandbox Code Playgroud)

  • 另外,显然此功能在(尚未发布)maven-gpg-plugin 版本 3.0.0 中自动处理:https://github.com/apache/maven-gpg-plugin/commit/11aca384c4005747d797dcc4857280d0d578d05f/ (3认同)