【问题标题】:Jenkins: ERROR: Error fetching remote repo 'origin'詹金斯:错误:获取远程仓库“来源”时出错
【发布时间】:2016-11-18 09:32:53
【问题描述】:

我是 Jenkins 的相对新手,我试图简单地从存储在 Bitbucket 上的代码运行构建。我正在使用 git。我已将作业源控制设置为 https 协议: 网址:https://myaccount@bitbucket.org/myaccount/myrepo.git 凭据:用户名/密码

'build' 部分指向根目录中的 pom.xml 并运行干净的测试 maven 目标

我有 Git 插件 2.5.2

我将 Jenkins 作为 Windows 服务 (Windows 10) 运行。

构建项目的错误是

ERROR: Timeout after 10 minutes

git.exe config --local --remove-section credential # timeout=10 错误:获取远程 repo 'origin' 时出错 hudson.plugins.git.GitException:无法从https://username@bitbucket.org/username/myrepo.git 获取 在 hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:799) 在 hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1055) 在 hudson.plugins.git.GitSCM.checkout(GitSCM.java:1086) 在 hudson.scm.SCM.checkout(SCM.java:495) 在 hudson.model.AbstractProject.checkout(AbstractProject.java:1270) 在 hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:604) 在 jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86) 在 hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:529) 在 hudson.model.Run.execute(Run.java:1720) 在 hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:531) 在 hudson.model.ResourceController.execute(ResourceController.java:98) 在 hudson.model.Executor.run(Executor.java:404) 引起:hudson.plugins.git.GitException: Command "git.exe -c core.askpass=true fetch --tags --progress https://username@bitbucket.org/username/myrepo.git +refs/heads/:refs/remotes/origin/ em>" 返回状态码 -1:

欢迎任何建议

【问题讨论】:

  • 尽管不允许(非交互式外壳),但 git 很有可能要求输入密码,这是一个私人仓库。您需要以其他方式提供密码。
  • 您能否在工作中的构建步骤中 ping bitbucket.org?

标签: git jenkins jenkins-plugins


【解决方案1】:

正如我在这里回答的 https://stackoverflow.com/a/43964812/908936

尝试使用

禁用 git 凭据缓存
git config --global --unset credential.helper

你可能还需要这样做

git config --system --unset credential.helper if this has been set in the system config file

【讨论】:

  • 我遇到了同样的问题,尝试运行上面的命令,它只发生在一个特定的公关建设者身上。任何其他解决方案请
【解决方案2】:

使用用户名/密码访问 repo 的任何具体原因?

另一种更方便、更安全的方法是使用 ssh。 按着这些次序: 如果尚未完成,请在您的 Jenkins 服务器中为您用来访问 bitbucket 的用户生成一个 rsa 密钥。

sudo su <bitbucket user> #if such user not already created, create it first.  
ssh-keygen 

每问一个问题就按回车键。

现在到家中隐藏的 .ssh 目录并复制您需要在下一步中粘贴到 bitbucket 密钥中的公钥。
vi ~/.ssh/id_rsa.pub

现在登录到同一个 bitbucket 帐户并转到:用户配置文件 -> 设置 -> 安全 -> SSH 密钥并将在 (2) 中复制的公钥粘贴到此处。 在您的脚本和设置中,将您的 bitbucket url 中的 'http' 替换为 'ssh'

现在再试一次,它应该可以工作了。

【讨论】:

  • 如果其中任何一个对您有用,请接受答案
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-05-31
  • 2019-11-11
  • 2019-05-23
  • 2015-06-14
  • 2018-07-04
  • 1970-01-01
相关资源
最近更新 更多