无法访问Jenkins的github repo?

时间:2017-08-26 10:14:32

标签: jenkins

我做了设置

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

1 个答案:

答案 0 :(得分:0)

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

尝试更改克隆的远程网址:

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