git 詹金斯:错误:获取远程仓库“来源”时出错
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38391601/
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
Jenkins: ERROR: Error fetching remote repo 'origin'
提问by Steerpike
I'm a relative novice with Jenkins and am trying to simply run a build from code stored on Bitbucket. I am using git. I have setup the job source control as https protocol as: url: https://[email protected]/myaccount/myrepo.gitcredentials: username/password
我是 Jenkins 的相对新手,我试图简单地从 Bitbucket 上存储的代码运行构建。我正在使用 git。我已将作业源代码管理设置为 https 协议: url: https://[email protected]/myaccount/myrepo.git凭据:用户名/密码
the 'build' section points to the pom.xml in the root and runs the clean test maven goal
'build' 部分指向根目录中的 pom.xml 并运行干净的测试 maven 目标
I have the Git plugin 2.5.2
我有 Git 插件 2.5.2
I am running Jenkins as a Windows service (Windows 10).
我正在将 Jenkins 作为 Windows 服务(Windows 10)运行。
The error on building the project is
构建项目的错误是
ERROR: Timeout after 10 minutes
git.exe config --local --remove-section credential # timeout=10 ERROR: Error fetching remote repo 'origin' hudson.plugins.git.GitException: Failed to fetch from https://[email protected]/username/myrepo.gitat hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:799) at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1055) at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1086) at hudson.scm.SCM.checkout(SCM.java:495) at hudson.model.AbstractProject.checkout(AbstractProject.java:1270) at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:604) at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:529) at hudson.model.Run.execute(Run.java:1720) at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:531) at hudson.model.ResourceController.execute(ResourceController.java:98) at hudson.model.Executor.run(Executor.java:404) Caused by: hudson.plugins.git.GitException: Command "git.exe -c core.askpass=true fetch --tags --progress https://[email protected]/username/myrepo.git+refs/heads/:refs/remotes/origin/" returned status code -1:
git.exe config --local --remove-section credential # timeout=10 错误:获取远程仓库“来源”时出错 hudson.plugins.git.GitException:无法从https://[email protected]/username/ 获取我的仓库在 hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:799) 在 hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1055) 在 hudson.plugins.git.GitSCM.checkout(GitSCM.java:1086) ) at hudson.scm.SCM.checkout(SCM.java:495) at hudson.model.AbstractProject.checkout(AbstractProject.java:1270) at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:604) at jenkins .scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:529) at hudson.model.Run.execute(Run.java:1720) at hudson.maven。 MavenModuleSetBuild.run(MavenModuleSetBuild.java:531) at hudson.model.ResourceController.execute(ResourceController.java:98) at hudson.model.Executor.run(Executor.java:404) 引起:hudson。plugins.git.GitException:命令“git.exe -c core.askpass=true fetch --tags --progresshttps://[email protected]/username/myrepo.git+refs/heads/ :refs/remotes/origin/" 返回状态代码 -1:
Any advice welcome
欢迎任何建议
回答by razon
as I answered here https://stackoverflow.com/a/43964812/908936:
正如我在这里回答https://stackoverflow.com/a/43964812/908936:
try to disable use of the git credential cache using
尝试禁用使用 git 凭据缓存
git config --global --unset credential.helper
You may also need to do
你可能还需要做
git config --system --unset credential.helper if this has been set in the system config file
回答by Manish Sharma
Any specific reason for using username/password for accessing the repo?
使用用户名/密码访问 repo 的任何具体原因?
Another way that is more convenient and secure is to use ssh. Follow these steps: If not already done, generate a rsa key in your Jenkins server for the user that you are using to access bitbucket.
另一种更方便和安全的方法是使用 ssh。请按照以下步骤操作: 如果尚未完成,请在您的 Jenkins 服务器中为您用来访问 bitbucket 的用户生成一个 rsa 密钥。
sudo su <bitbucket user> #if such user not already created, create it first.
ssh-keygen
Press enter for every question asked.
对提出的每个问题按回车键。
Now got to the hidden .ssh directory in home and copy the public key that you need to paste in bitbucket keys in next step.vi ~/.ssh/id_rsa.pub
现在到家中隐藏的 .ssh 目录并复制您需要在下一步中粘贴到 bitbucket 密钥中的公钥。vi ~/.ssh/id_rsa.pub
Now login to the same bitbucket account and go to: User Profile -> Setting -> Security -> SSH keys and paste here the public key copied in (2). In your scripts and settings, replace the 'http' in your bitbucket url with 'ssh'
现在登录到同一个 bitbucket 帐户并转到:用户配置文件 -> 设置 -> 安全性 -> SSH 密钥并将在 (2) 中复制的公钥粘贴到此处。在您的脚本和设置中,将 bitbucket url 中的“http”替换为“ssh”
Now try again and it should work.
现在再试一次,它应该可以工作。