Jenkins错误-ssh:连接到主机端口22:连接被拒绝

时间:2019-10-10 13:38:32

标签: git jenkins

在Windows机器上像这样运行Jenkins-

java -jar jenkins.war --httpPort=8080

使用GIT(不是scm的github)作为git插件配置了一个项目。使用提供的凭据为SSH username with private key。储存库网址类似于- ssh://username@host.domain.com:/data/repo/xyz

此git存储库位于我没有root访问权限的linux计算机上。在Jenkins页面上配置项目时没有错误。但是构建失败并出现以下错误:

Git检出,克隆等可在运行Jenkins的Windows计算机上的命令行上运行。

ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Command "C:\Program Files\Git\bin\git.exe fetch --tags --progress -- ssh:///user@host.domain.com:/data/sde-repo/SOA +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout: 
stderr: ssh: connect to host  port 22: Connection refused
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2174)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1866)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:78)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:547)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$2.execute(CliGitAPIImpl.java:760)
    at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1152)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1192)
    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:1815)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:97)
    at hudson.model.Executor.run(Executor.java:429)
ERROR: Error cloning remote repo 'origin'
Finished: FAILURE

在我看来,Jenkins无法识别主机名,因为在此错误中主机名为空-

ssh: connect to host port 22: Connection refused

是这样吗?还是我走错了方向?

1 个答案:

答案 0 :(得分:0)

我尝试了@James Z注释中的一些内容,例如删除了一个/,在末尾添加了/等。但是,它通过在<源代码管理”部分下的GIT存储库网址中添加双引号而起作用。在詹金斯页面上是这样的-

"ssh://user@host.domain.com:/data/sde-repo/somefolder"

我不确定为什么它需要双引号URL。