当我尝试设置作业以从 git 存储库构建项目时,出现错误:
Failed to connect to repository : Command "git ls-remote -h ssh://git@ssh://git@host.com/path/to/repos.git HEAD" returned status code 128:
stdout:
stderr: Permission denied (publickey).
fatal: The remote end hung up unexpectedly
在 Jenkins 中,我安装了 SSH Agent 插件和 Git 插件。
我可以使用以下内容添加构建步骤:
git ls-remote -h ssh://git@host.com/path/to/repos.git HEAD
运行构建,一切正常!
这告诉我一切都已正确设置:
- 键和键的位置。
- Jenkins/Manage Jenkins/Manage Plugins -> SSH 代理插件和 Git 插件。
- Jenkins/Manage Jenkins/Manage Credentials 条目正确。
这似乎不适用于源代码管理,但它适用于构建前/构建/构建后操作。
在构建过程之前没有激活 Ssh 代理是否有问题?
在此先感谢任何可以提供帮助的人。
最佳答案
“在构建过程之前未激活 SSH 代理是否存在问题?” - 是的,这很烦人。
我确实在我的搜索中读到“某处”,他们计划在未来使 SSH 代理正确地环绕 git 和其他插件。
如果您使用 SSH 代理设置运行一个简单的 shell 命令,您会在构建的控制台输出中清楚地看到它在 shell 命令之前和之后启动和停止,当输入 git 详细信息时不会发生这种情况。
只需继续使用目前描述的构建步骤...
关于git jenkins scm 插件权限被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15361398/