git 本地 Jenkins 无法验证远程 Gitlab 私有存储库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18636145/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Local Jenkins can't authenticate remote Gitlab private repository
提问by Andrian Durlestean
I installed Jenkins on windows with all addons that I need, I think so. When i create a new job and in Repository URL i write my url
我在 Windows 上安装了 Jenkins 以及我需要的所有插件,我认为是这样。当我创建一个新工作并在 Repository URL 中我写我的 url
http://git.*****.org/*****/seleniumproject.git
http://git.*****.org/*****/seleniumproject.git
and it shows
它显示
Help for feature: Repository URL
Failed to connect to repository : Command "C:\Program Files (x86)\Git\bin\git.exe ls-remote -h http://git.*****.org/*****/seleniumproject.git HEAD" returned status code 128:
stdout:
stderr: fatal: Authentication failed for 'http://git.*****.org/*****/seleniumproject.git'`
My question: how can I authenticate to my remote gitlab?! I have folder with .ssh with all keys but don't know what to do...
我的问题:如何对远程 gitlab 进行身份验证?!我有带有所有键的 .ssh 文件夹,但不知道该怎么做...
Update:strange because my TortoiseGit is working perfectly
更新:很奇怪,因为我的 TortoiseGit 运行良好
My Fix :
我的修复:
- Go to jenkins path and save .ssh folder in root example
C:\Jenkins\.ssh.ssh folder u can find inC:\Users\yourname\.ssh - Go to Jenkins > Manage Jenkins > Manage Credentials, here you can add your private key or select from the jenkins master !/.ssh
- Go to Jenkins > Manage Jenkins > Configure System in git executable wrote this
C:\Program Files (x86)\Git\cmd\git.exepath must be with cmd - Create new job and in repository url add
ssh://[email protected]:/name/projet.git
- 转到 jenkins 路径并将 .ssh 文件夹保存在根示例
C:\Jenkins\.ssh.ssh 文件夹中,您可以在其中找到C:\Users\yourname\.ssh - 转到 Jenkins > Manage Jenkins > Manage Credentials,在这里您可以添加您的私钥或从 jenkins master 中选择!/.ssh
- 转到 Jenkins > Manage Jenkins > Configure System 在 git 可执行文件中写道,此
C:\Program Files (x86)\Git\cmd\git.exe路径必须使用cmd - 创建新作业并在存储库 url 添加
ssh://[email protected]:/name/projet.git
采纳答案by Andrian Durlestean
My Fix :
我的修复:
- Go to jenkins path and save .ssh folder in root example C:\Jenkins.ssh .ssh folder u can find in C:\Users\yourname.ssh
- Go to Jenkins > Manage Jenkins > Manage Credentials, here you can add your private key or select from the jenkins master !/.ssh
- Go to Jenkins > Manage Jenkins > Configure System in git executable wrote this C:\Program Files (x86)\Git\cmd\git.exe path must be with cmd
- Create new job and in repository url add ssh://[email protected]:/name/projet.git
- 转到 jenkins 路径并将 .ssh 文件夹保存在根示例 C:\Jenkins.ssh .ssh 文件夹中,您可以在 C:\Users\yourname.ssh 中找到
- 转到 Jenkins > Manage Jenkins > Manage Credentials,在这里您可以添加您的私钥或从 jenkins master 中选择 !/.ssh
- 转到 Jenkins > Manage Jenkins > Configure System in git executable 写了这个 C:\Program Files (x86)\Git\cmd\git.exe path must be with cmd
- 创建新作业并在存储库 url 添加 ssh://[email protected]:/name/projet.git
回答by VonC
I have folder with .ssh with all keys
我有带有所有键的 .ssh 文件夹
Those keys won't never been read, if you keep using an http(s) url.
如果您继续使用 http(s) url,这些密钥将永远不会被读取。
You should use an ssh url, and first make sure that this works properly:
您应该使用 ssh url,并首先确保它正常工作:
ssh -Tv ssh://git@git.*****.org
(assuming the user account you need on the server side is 'git')
(假设您在服务器端所需的用户帐户是“ git”)
Note that the section on SSH of this guideis of interest here:
请注意,本指南的 SSH 部分在这里很有趣:
you have installed TortoiseGIT
你已经安装了 TortoiseGIT


If you have ever installed TortoiseGit on the computer you're setting up your keys on, you may encounter problems.
TortiseGit creates an environment variable that configures Plink as your SSH keystore, which may conflict when you try to use Git and SSH.
No matter how you change your config or uninstall TortoiseGit, that environment variable persists and until you delete it, Git will not look to your regular.sshdirectory to find the proper key.In our case environment variable looked like this:
如果您曾经在设置密钥的计算机上安装了 TortoiseGit,您可能会遇到问题。
TortiseGit 创建了一个环境变量,将 Plink 配置为您的 SSH 密钥库,当您尝试使用 Git 和 SSH 时,这可能会发生冲突。
无论您如何更改配置或卸载 TortoiseGit,该环境变量都会持续存在,并且在您删除它之前,Git 不会查找您的常规.ssh目录以找到正确的密钥。在我们的例子中,环境变量如下所示:
GIT_SSH=c:\Program Files\Putty\plink.exe.
Environment variables can be found here:
环境变量可以在这里找到:
- Windows XP:
Control Panel → System Properties → Advanced → Environment variables - Windows 7:
Control Panel → System → Advanced system settings → Environment variables
- 视窗 XP:
Control Panel → System Properties → Advanced → Environment variables - Windows 7的:
Control Panel → System → Advanced system settings → Environment variables
回答by Digeek
Try using C:\Program Files (x86)\Git\cmd\gitk.cmdinstead of \bin\git.exe. If not solved, then Hereis information how to configure ssh. Sometimes you may also get public key error, which is solved here. If you want to generate new ssh keys, thisarticle will help you.
尝试使用C:\Program Files (x86)\Git\cmd\gitk.cmd而不是\bin\git.exe. 如果没有解决,那么这里是如何配置ssh的信息。有时你也可能会得到公钥错误,这里解决了。如果你想生成新的SSH密钥,该文章将帮助您。

