Jenkins Git集成 - 如何禁用SSL证书验证

Son*_*tty 10 git jenkins jenkins-plugins

我在从Jenkins创建工作时遇到以下错误.如何在Jenkins中禁用证书验证?

从Git Bash我可以使用git config --global http.sslVerify false命令来禁用它,但不知道如何从Jenkins使用它.

错误:

Failed to connect to repository : Command "C:\Program Files (x86)\Git\cmd\git.exe ls-remote -h url ofmy repository.git HEAD" returned status code 128:
stdout:
stderr: fatal: unable to access 'url of my git/': SSL certificate problem: self signed certificate in certificate chain
Run Code Online (Sandbox Code Playgroud)

Jam*_*esD 15

最佳选择是将自签名证书添加到证书库

获取服务器证书树可以使用chrome完成.

  1. 导航为服务器地址.单击挂锁图标并查看证书.将所有证书链导出为base64编码文件(PEM)格式.

  2. 将证书添加到GIT信任配置文件的信任链中在运行该作业的计算机上的Git bash中运行以下命令:

"git config --list".

找到http.sslcainfo显示证书信任文件所在位置的配置.3.将所有证书复制到信任链文件中,包括"- -BEGIN- -""- -END- -".确保将ROOT证书链添加到证书文件中

这应该可以解决您使用自签名证书和使用GIT的问题.

不建议

另一种方法是远程进入您的奴隶并运行以下内容:

git config --global http.sslVerify false

这将保存到此实例从不进行SSL验证的全局配置,不建议这样做,它应该仅在测试时使用,然后再次禁用.它应该如上所述正确完成.


Jac*_* Wu 7

作为补充,我已经坚持了几个小时,这是我发现的与 SSL 相关的内容

添加

-Dorg.jenkinsci.plugins.getclient.GitClient.untrustedSSL=true 
Run Code Online (Sandbox Code Playgroud)

作为 java jnlp 命令的参数,

并将 GIT_SSL_NO_VERIFY=true 设置为环境变量,因此从机端的启动从机命令现在看起来像(不确定某些参数是否重复)

export GIT_SSL_NO_VERIFY=true

java -Dorg.jenkinsci.plugins.getclient.GitClient.untrustedSSL=true -jar slave.jar -jnlpUrl ${jenkins_url}/computer/${slave_name}/slave-agent.jnlp -secret ${secret} -noCertificateCheck
Run Code Online (Sandbox Code Playgroud)

你可能需要同样的

-noCertificateCheck
Run Code Online (Sandbox Code Playgroud)

在尝试调用 jenkins-cli.jar 时

(至https://blog.csdn.net/froghui/article/details/39641221

因为每次 jenkins 从站启动 git 操作时,它都是一个干净的环境,由 jenkins git 插件处理


rav*_*eed 5

创建 Freestyle 项目并添加“Windows 批处理命令”并添加

git config http.sslVerify false 或 git config --config http.sslVerify false

完成后,保存并构建作业

现在您的 jenkin 配置为不进行 ssl 验证。现在成功构建后,您可以删除批处理命令构建步骤并为您的配置编辑相同的项目。

  • 仅在命令行上运行“git config --global http.sslVerify false”不起作用,但这样做了。不过,我必须指定“git”的绝对路径;詹金斯似乎没有使用“PATH”。 (2认同)