输入存储库URL时,Jenkins显示为“无法连接到存储库”

时间:2019-01-30 12:16:54

标签: git jenkins github jenkins-pipeline jenkins-plugins

这是显示的错误消息

Failed to connect to a repository: Command "C:\Program Files\Git\bin\git.exe ls-remote -h https://github.com/org/project.git HEAD" returned status code 128:
stdout: 
stderr: Login failed, use ctrl+c to cancel basic credential prompt. 
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/org/project.git/'

为显示的错误附加屏幕截图:- enter image description here

我经历了多个有关配置问题的平台,但似乎没有一个与之同步。他们中的一些人谈论git可执行文件路径似乎正确,但不知道在这里实际验证了什么,说找不到git仓库。即使提供了有效的凭据,它也会显示相同的错误。

在运行100个构建后,它开始显示此错误消息。在尝试从头开始配置的那些构建显示上述错误消息之后,不知道出了什么问题。但是在另一台具有相同设置的计算机上可以运行作业。有人可以让我知道机器是否也有可能出现问题?

工作日志:-

Started by user Tom
Building in workspace C:\Program Files (x86)\Jenkins\workspace\Create
using credential "xyz"
git.exe rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
git.exe config remote.origin.url giturl # timeout=10
Fetching upstream changes from giturl
git.exe --version # timeout=10
using GIT_ASKPASS to set credentials xyz git
git.exe fetch --tags --force --progress giturl +refs/heads/*:refs/remotes/origin/*
ERROR: Error fetching remote repo 'origin'

    hudson.plugins.git.GitException: Failed to fetch from giturl
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:894)
    at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1148)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1179)
    at hudson.scm.SCM.checkout(SCM.java:504)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1208)
    at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:574)
    at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:499)
    at hudson.model.Run.execute(Run.java:1810)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:97)
    at hudson.model.Executor.run(Executor.java:429)
    Caused by: hudson.plugins.git.GitException: Command "C:\Program Files\Git\bin\git.exe fetch --tags --force --progress giturl +refs/heads/*:refs/remotes/origin/*" returned status code 128:
    stdout: 
    stderr: remote: Not Found
    fatal: repository 'giturl/' not found
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2042)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1761)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$400(CliGitAPIImpl.java:72)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:442)
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:892)
    ... 11 more
    ERROR: Error fetching remote repo 'origin'
    Finished: FAILURE

2 个答案:

答案 0 :(得分:0)

从日志中,我看到您正在尝试获取伪造的giturl而不是存储库的实际地址。

"C:\Program Files\Git\bin\git.exe fetch --tags --force --progress giturl +refs/heads/*:refs/remotes/origin/*" returned status code 128:
...                                                           ####^HERE^####
...
fatal: repository 'giturl/' not found

因此,您需要指定Git存储库的实际URL而不是giturl(类似git@github.com:Company/Repo.git)。

答案 1 :(得分:0)

感谢您的建议,我已按照以下步骤解决了问题

1。通过命令行运行此 git.exe ls远程URL

2。然后提供git凭据

3。成功完成上述步骤后,您将找到存储库的头...如下面的屏幕快照所示 [1]:https://i.stack.imgur.com/AYj7k.jpg

4。现在转到Jenkins,在SCM &&中提供您的git存储库URL,然后在凭据中添加git的凭据。

然后将清除上述问题“无法连接到存储库”