2017-08-30 145 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