阡陌 发表于 2023-12-26 00:09:45

解决向 Jenkins( Windows) 添加 Git 仓库时报错的问题



向 Jenkins( Windows) 添加 Git 仓库时总是报错,当添加 HTTPS 仓库地址时报错:

>Failed to connect to repository : Command "C:\Program Files\Git\bin\git.exe ls-remote -h -- >https://git.\***.com/gitlab/git.git HEAD" returned status code 128:
>
>stdout:
>
>stderr: fatal: unable to access 'https://git.***.com/gitlab/git.git/': OpenSSL SSL_connect: >SSL_ERROR_SYSCALL in connection to git.***.com:443

当添加 SSH 仓库地址时报错:

>Failed to connect to repository : Command "C:\Program Files\Git\bin\git.exe ls-remote -h -- >git@git.\***.com:gitlab/git.git HEAD" returned status code 128:
>stdout:
>stderr: Host key verification failed.
>fatal: Could not read from remote repository.
>
>Please make sure you have the correct access rights
>and the repository exists.

<!--more-->



![](https://file.mculoop.com/images/2022/04/96e93b9b954d5061.jpg)

即便给 Git 配置了 SSL 证书,创建了秘钥,问题依旧。最后查出原因是安装 Jenkins 选择了使用 `LocalSystem` 账户运行服务,这导致 Git 不能使用本地用户所做的配置,所以秘钥和证书都不起作用。

![](https://file.mculoop.com/images/2022/04/cba2c6a885935cdf.jpg)

解决方法是在服务管理器中将登录用户换为你的系统账户。

![](https://file.mculoop.com/images/2022/04/659f8d8aa513cc65.jpg)


或者重新安装 Jenkins,选择你所使用的本地账户或域账户作为服务的启动账户。

![](https://file.mculoop.com/images/2022/04/f5405aa501ecb547.jpg)

注意,使用本地账户时输入框要输入 `计算机名\账户名`。


页: [1]
查看完整版本: 解决向 Jenkins( Windows) 添加 Git 仓库时报错的问题