gpt4 book ai didi

maven 3 站点部署卡在 Jenkins 构建中的身份验证提示中

转载 作者:行者123 更新时间:2023-12-02 17:42:52 27 4
gpt4 key购买 nike

使用 site-deploy 时如何去掉这个提示?“你确定要继续连接吗?”

我知道这个问题已被多次询问(linklink),但推荐的解决方案对我不起作用,我将解释原因。

哦,我发布了几乎完全相同的问题 here

解决方案是:

# Run this manually:
ssh -o UserKnownHostsFile=foo javadoc.foo.com

# Take that file and put it in your private DAV share, and then
ssh -o UserKnownHostsFile=/private/<account>/known_hosts javadoc.foo.com

它在 99% 的时间里都运行良好,但是使用这个解决方案,每隔一段时间我们就会在日志中一遍又一遍地得到以下文本:

WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
3d:69:41:8a:ec:d1:4c:d9:75:ef:7d:71:b7:7d:61:d0.
Please contact your system administrator.
Add correct host key in known_hosts to get rid of this message.
Do you want to delete the old key and insert the new key? (yes/no)

所以,回到我的问题:简而言之,问题是这样的:当我运行 mvn site-deploy 时,它陷入了 Jenkins 的无限循环:

The authenticity of host 'javadoc.foo.com' can't be established.
RSA key fingerprint is 3d:69:41:8a:ec:d1:4c:d9:75:ef:7d:71:b7:7d:61:d0.
Are you sure you want to continue connecting? (yes/no)
The authenticity of host 'javadoc.foo.com' can't be established.
RSA key fingerprint is 3d:69:41:8a:ec:d1:4c:d9:75:ef:7d:71:b7:7d:61:d0.
Are you sure you want to continue connecting? (yes/no)

发生这种情况的机器是 CloudBees 机器,因此它不是我们拥有的机器。换句话说,每次我们进行构建时,都会为我们提供一台全新的机器。

我们的 settings.xml 是这样的:

<server>
<id>javadoc.foo.com</id>
<username>username</username>
<password>password</password>
</server>

如果这是我们拥有和控制的机器,我们可以在那里手动 ssh 并运行 ssh 命令一次,这样就可以解决这个问题,但正如我所说,这些机器是动态配置给我们的。

因为我们使用的是 maven 3 而不是 maven 2,所以我们不能将以下内容添加到 settings.xml 的服务器部分:

<configuration>
<knownHostsProvider implementation="org.apache.maven.wagon.providers.ssh.knownhost.NullKnownHostProvider">
<hostKeyChecking>no</hostKeyChecking>
</knownHostsProvider>
</configuration>

有没有办法:

  1. 以编程方式回答是(这不是自由式 Jenkins 工作;这是 Maven 项目。)
  2. 站点部署的替代方案(pom.xml 中的 ant 代码?)
  3. 如果这个问题没有得到回答,让站点部署失败,这样 Jenkins 构建就不会因为这个问题一遍又一遍地重复而占用大量磁盘空间。
  4. 告诉站点部署插件将 stricthostkeychecking 设置为“no”

我想避免任何可能调整 ssh 设置的预构建步骤;我宁愿调整 settings.xml、pom.xml 或 maven 选项。

尽管如此,我愿意接受任何建议。

最佳答案

您可以设法使用此settings.xml 配置让它工作:

<server>
<id>site</id>
<username>_your_login_user_</username>
<privateKey>_path_to_key_identify_file</privateKey>
<configuration>
<strictHostKeyChecking>no</strictHostKeyChecking>
<preferredAuthentications>publickey,password</preferredAuthentications>
<interactive>false</interactive>
</configuration>
</server>

连同以下 pom.xml :

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.6</version>
<dependencies>
<dependency><!-- add support for ssh/scp -->
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh</artifactId>
<version>2.12</version>
</dependency>
</dependencies>
</plugin>

一个问题 https://issues.apache.org/jira/browse/WAGON-467一直在解决 strictHostKeyChecking 参数的 wagon-ssh 插件,并已在最新版本中解决。

关于maven 3 站点部署卡在 Jenkins 构建中的身份验证提示中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18367206/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com