我无法以某种方式配置 git 存储库 url,Jenkins 可以访问它。
在“项目 > 配置 > 源代码管理”下,我将存储库 URL 设置为“git@store:repositories/testproject.git”
我收到此错误:
Failed to connect to repository : Command "/usr/bin/git -c core.askpass=true ls-remote -h git@store:repositories/testproject.git HEAD" returned status code 128:
stdout:
stderr: Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,password).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Run Code Online (Sandbox Code Playgroud)
使用该 URL 的访问适用于 shell:
jenkins@dilbert:~$ /usr/bin/git -c core.askpass=true ls-remote -h git@store:repositories/testproject.git
git@store's password:
4fd35a4f528e2f2921a52cfd03918b7cbde3d253 refs/heads/master
Run Code Online (Sandbox Code Playgroud)
我被要求输入密码并且它有效。
我将相同的密码与 Jenkins 中的凭据关联到“git/”,我还尝试了“git@store/”。没有一个工作。
请注意,这不是关于 github,而是关于本地 git 存储库。
更新:
将 jenkins master 的 pub key 添加到 build slave,有助于使配置正常工作:
ssh-copy-id jenkins@dilbert
Run Code Online (Sandbox Code Playgroud)
现在构建失败了:
> /usr/bin/git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> /usr/bin/git config remote.origin.url git@store:repositories/testproject.git # timeout=10
Fetching upstream changes from git@store:repositories/testproject.git
> /usr/bin/git --version # timeout=10
> /usr/bin/git -c core.askpass=true fetch --tags --progress git@store:repositories/testproject.git +refs/heads/*:refs/remotes/origin/*
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from git@store:repositories/testproject.git
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:735)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:983)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1016)
at hudson.scm.SCM.checkout(SCM.java:484)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1270)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:609)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:531)
at hudson.model.Run.execute(Run.java:1751)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:89)
at hudson.model.Executor.run(Executor.java:240)
Caused by: hudson.plugins.git.GitException: Command "/usr/bin/git -c core.askpass=true fetch --tags --progress git@store:repositories/testproject.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout:
stderr: Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,password).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Run Code Online (Sandbox Code Playgroud)
store 是 jenkins 的主人,dilbert 是构建的奴隶。从主到从的 ssh 工作。
jenkins@store:~$ ssh dilbert uptime
16:06:21 up 3 days, 18:53, 13 users, load average: 0,31, 0,38, 0,50
Run Code Online (Sandbox Code Playgroud)
任何想法如何调试?
身份验证通过 ssh 进行。您是否将 jenkins 用户的公共 ssh-key 添加到您的 git-server 上的 git-user 中?
如果您需要有关如何设置 ssh 身份验证的说明,请告诉我,我将在此处编辑这篇文章。
/编辑:
很高兴你让它运行起来。我在 jenkins 官方网站上查看了有关配置的 ssh 部分的详细手册,但找不到任何手册。
所以这里有一个快速概述 - 如果这是您需要的,请告诉我。
jenkins@dilbert:~/.ssh$ ssh-copy-id git@store
将 jenkins@dilbert ssh 公钥复制到 git 服务器 归档时间: |
|
查看次数: |
55410 次 |
最近记录: |