2017-08-30 211 views
0

我想爲我的maven項目使用Jenkins master slave體系結構。我在Linux機器上有windows機器上的Jenkins master和slave。現在的問題是當我運行我的Jenkins腳本時,它給了我一個像無法初始化git倉庫的錯誤,因爲Jenkins正試圖在Linux奴隸機器上執行git.exe。任何人都可以讓我知道我該如何解決它?如何在jenkins管道腳本中指定jenkins master git地址

以下是我的詹金斯管道腳本和錯誤日誌

node ('lx-dotoolsd1') 
{ 
    stage 'Checkout' 
    git branch: 'master', credentialsId: 'ee44e971-4cce-4e59-95b6- 
    da222007775b', url: ' http://[email protected]:7990/scm/phoen/audit- 
    confirmation.git' 
    stage 'Test' 
    def pom = readMavenPom file: 'pom.xml' 
    print "Build: " + pom.version 
    env.POM_VERSION = pom.version 
    //batch 'mvn clean compile install' 
    //junit '**/target/surefire-reports/TEST-*.xml' 
    currentBuild.description = "v${pom.version} (${env.branch})" 
} 

錯誤是如下

Started by user Patel,Heena 
[Pipeline] node 
Running on lx-dotoolsd1 in /var/jenkins/workspace/pipelineTest 
[Pipeline] { 
[Pipeline] stage (Checkout) 
Entering stage Checkout 
Proceeding 
[Pipeline] git 
Cloning the remote Git repository 
Cloning repository http://[email protected]:7990/scm/phoen/audit-confirmation.git 
> git.exe init /var/jenkins/workspace/pipelineTest # timeout=10 
ERROR: Error cloning remote repo 'origin' 
hudson.plugins.git.GitException: Could not init /var/jenkins/workspace/pipelineTest 
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$5.execute(CliGitAPIImpl.java:656) 
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$2.execute(CliGitAPIImpl.java:463) 
at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$1.call(RemoteGitImpl.java:152) 
at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$1.call(RemoteGitImpl.java:145) 
at hudson.remoting.UserRequest.perform(UserRequest.java:152) 
at hudson.remoting.UserRequest.perform(UserRequest.java:50) 
at hudson.remoting.Request$2.run(Request.java:332) 
+0

您是否檢查過節點屬性?你在那裏添加了你的奴隸機器的Git路徑嗎? – ANIL

+0

我不知道,你能否詳細說一下你說的 – Axata

回答

0

此問題發生作爲Linux Node正在訪問來自全球工具配置的Git路徑。

因爲,您的主機是Windows Git路徑指向Git.exe

我認爲你沒有設置你的奴隸機器的Git路徑。

轉到http://<JENKINS_URL>/computer/<NODE_NAME>/configure,這會將您帶到您的從站配置頁面。有Node Properties檢查Tool LocationList of Tool Location選擇Git並添加安裝在你的奴隸機器Git的GIT_HOME路徑。

enter image description here