2012-11-27 116 views
1

我設置jenkins並存儲在同一臺服務器上。 Stash通過http運行良好。爲了讓Jenkins連接到Stash,我創建了一個ssh(使用Jenkins用戶,密鑰存儲在/var/lib/jenkins/.ssh/id_rsa.pub中)。如指南所述,我將此密鑰添加到了我的配置文件中,並在Administartion>服務器設置中啓用了ssh。Jenkins和Stash設置ssh密鑰

在詹金斯我安裝了插件的Git並在genarl配置:

全局配置user.name值

全局配置user.email價值

而在項目配置我成立以下領域:

庫網址:SSH://[email protected]:7999/AT/repository1.git

如果我跑ŧ他工作那麼我得到以下錯誤:

Building in workspace /var/lib/jenkins/jobs/Test Job/workspace 
Checkout:workspace//var/lib/jenkins/jobs/Test Job/workspace - [email protected] 
Using strategy: Default 
Cloning the remote Git repository 
Cloning repository ssh://[email protected]:7999/AT/repository1.git 
git --version 
git version 1.7.12.4 
ERROR: Error cloning remote repo 'origin' : Could not clone ssh://[email protected]:7999/AT/repository1.git 
hudson.plugins.git.GitException: Could not clone ssh://[email protected]:7999/AT/repository1.git 
    at hudson.plugins.git.GitAPI.clone(GitAPI.java:273) 
    at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1044) 
    at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:986) 
    at hudson.FilePath.act(FilePath.java:852) 
    at hudson.FilePath.act(FilePath.java:825) 
    at hudson.plugins.git.GitSCM.determineRevisionToBuild(GitSCM.java:986) 
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1142) 
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1324) 
    at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:676) 
    at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88) 
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:581) 
    at hudson.model.Run.execute(Run.java:1518) 
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46) 
    at hudson.model.ResourceController.execute(ResourceController.java:88) 
    at hudson.model.Executor.run(Executor.java:236) 
Caused by: hudson.plugins.git.GitException: Command "/home/danilo/libexec/git-core/git clone --progress -o origin ssh://[email protected]:7999/AT/repository1.git /var/lib/jenkins/jobs/Test Job/workspace" returned status code 128: 
stdout: Cloning into '/var/lib/jenkins/jobs/Test Job/workspace'... 

stderr: Host key verification failed. 
fatal: Could not read from remote repository. 

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

    at hudson.plugins.git.GitAPI.launchCommandIn(GitAPI.java:897) 
    at hudson.plugins.git.GitAPI.access$000(GitAPI.java:42) 
    at hudson.plugins.git.GitAPI$1.invoke(GitAPI.java:269) 
    at hudson.plugins.git.GitAPI$1.invoke(GitAPI.java:248) 
    at hudson.FilePath.act(FilePath.java:852) 
    at hudson.FilePath.act(FilePath.java:825) 
    at hudson.plugins.git.GitAPI.clone(GitAPI.java:248) 
    ... 14 more 
Trying next repository 
ERROR: Could not clone repository 
FATAL: Could not clone 
hudson.plugins.git.GitException: Could not clone 
    at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1056) 
    at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:986) 
    at hudson.FilePath.act(FilePath.java:852) 
    at hudson.FilePath.act(FilePath.java:825) 
    at hudson.plugins.git.GitSCM.determineRevisionToBuild(GitSCM.java:986) 
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1142) 
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1324) 
    at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:676) 
    at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88) 
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:581) 
    at hudson.model.Run.execute(Run.java:1518) 
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46) 
    at hudson.model.ResourceController.execute(ResourceController.java:88) 
    at hudson.model.Executor.run(Executor.java:236) 
+0

您可以使用ssh命令連接到存儲庫服務器嗎? –

回答

3

我有一個類似的問題 - 你需要你的藏匿服務器添加到您的known_hosts詹金斯服務器上。

登錄到您的詹金斯服務器和ssh到您的存儲服務器。這將爲您的用戶的known_hosts文件中的存儲服務器添加一個條目。

然後將known_hosts文件複製到$ JENKINS_HOME/.ssh並將文件所有者更改爲jenkins。

+0

對於我來說,只是ssh沒有工作,我不得不嘗試克隆known_hosts的ssh repo以因某些原因添加正確的密鑰 – Matan

0

我得到了一個無效的URL,通常看起來像SCP命令,這是不同於git命令相同的確切錯誤。

我本來有:

ssh://[email protected]:~/repos/newrepo.git 

而改爲:

ssh://[email protected]/~/repos/newrepo.git 

我設置的東西了詹金斯。一旦我在命令行中正常工作,那麼我在Jenkins的工作就可以正常工作。