【问题标题】:Unable to access github repo from Jenkins?无法从 Jenkins 访问 github 存储库?
【发布时间】:2018-02-04 06:21:22
【问题描述】:

我做了设置

1) 配置全局安全中的 Github Oauth,我必须指定 clientID、secret 等..

2) 我还将jenkins机器的公钥添加到我的github帐户中

3) 我去 blueocean 并尝试创建管道,所以它要求我提供个人访问令牌,所以我这样做并成功创建了管道。

现在我运行了一个简单的 Job,但它失败了,因为它无法连接到 repo。不知道为什么?

> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url https://github.com/helloinc/test-repo.git # timeout=10
Fetching without tags
Fetching upstream changes from https://github.com/helloinc/test-repo.git
 > git --version # timeout=10
using GIT_ASKPASS to set credentials GitHub Access Token
 > git fetch --no-tags --progress https://github.com/helloinc/test-repo.git +refs/heads/jenkins-test:refs/remotes/origin/jenkins-test
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from https://github.com/helloinc/test-repo.git
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:817)
    at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1084)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1115)
    at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:113)
    at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:85)
    at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:75)
    at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47)
    at hudson.security.ACL.impersonate(ACL.java:260)
    at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: hudson.plugins.git.GitException: Command "git fetch --no-tags --progress https://github.com/helloinc/test-repo.git +refs/heads/jenkins-test:refs/remotes/origin/jenkins-test" returned status code 128:
stdout: 
stderr: error: The requested URL returned error: 403 Forbidden while accessing https://github.com/helloinc/test-repo.git/info/refs

fatal: HTTP request failed

【问题讨论】:

  • This questionthis one 密切相关,请查看this answer
  • 尝试首先检查它是否通过ssh -T git@github.com通过您的Github帐户进行了身份验证

标签: jenkins


【解决方案1】:

我不熟悉 jenkins,但也许你不应该使用 HTTP 协议。

尝试更改克隆的远程url:

git remote set-url origin git@github.com:helloinc/test-repo.git

【讨论】:

  • 我不确定在哪里?用户界面非常混乱,到处都是
  • 您是否手动输入完整的 URL?如果是,只需从这一步重做一个新的。
  • 没有。它会自动配置它
  • 看起来您可以使用 UI 弹出控制台和 cd 到正确的目录以调整 URL。
猜你喜欢
  • 1970-01-01
  • 2015-01-18
  • 2020-12-21
  • 1970-01-01
  • 2018-11-02
  • 2018-09-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多