git jenkins scm 插件权限被拒绝

标签 git ssh jenkins ssh-agent

当我尝试设置作业以从 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/

相关文章:

git - 使用 git merge 两个非常不同的分支?

python - 使用Paramiko实现跳转主机(端口转发)时涉及的主机/IP地址和端口的说明

linux - .sh 文件的 CI Jenkins 权限被拒绝

jenkins - Jenkinsfile 参数化构建中的环境和参数之间有什么关系?

Git post-receive 仅 checkout 那些在推送中修改/添加的文件?

GitLab 自定义 wiki 侧边栏不起作用

git - 运行 git commit 时与编辑器相关的错误?

ssh - 更改给定主机的 ssh 身份

php - Unix `at` 命令通过 PHP

java - 无法启动 Jenkins war 文件