简体   繁体   中英

Setting up git in Jenkins for windows and unix machine

Hi I have jenkins set up with three unix machines slaves binding with ssh keys and able to do git clone successfully..

Now I want to add windows machine for the same master with ssh concept. I have copied one of the above slave machine ssh keys and did manual git clone command works fine.

Similary I tried to clone git in jenkins. Below are two observations.

  1. Updated "git installation" path in "“Manage Jenkins” –> “Configure System ” to "\\C:\\Program Files (x86)\\Git\\cmd\\git.com" from "git" as per http://computercamp-cdwilson-us.tumblr.com/post/48589650930/jenkins-git-clone-via-ssh-on-windows-7-x64 . In this case git clone successful for windows machine job, but other unix machine jobs were failed clone with an error..hudson.plugins.git.GitException: Error performing command: C:\\Program Files (x86)\\Git\\cmd\\git.cmd rev-parse --is-inside-work-tree

  2. Updated "git installation" path in "“Manage Jenkins” –> “Configure System ” to "git". In this case unix machine jobs were successfully cloned, but windows machine job was failed to clone with an error...ERROR: Error cloning remote repo 'origin' : Could not clone ssh://git@....... .

So we need two different path for unix and windows jobs or update one common path in which both the jobs (unix and window) runs successfully.

Any help on this issue highly appreciated..Thanks.

Each Jenkins slave configuration can have git tool config which overrides the global config.

Click "Manage Jenkins" -> "Manage nodes" -> click one of the slaves -> click "Configure" on the left -> Check the box named "Tool locations". Click "Add". From the pop-up menu choose "Git". Enter path to the git executable on that slave.

Please use C:\\Program Files\\git\\Cmd\\git.exe as the git environment variable for the windows slave configuration in Jenkins.

1) Manage Jenkins 2) Manage Nodes 3) Select Windows slave -> go to configuration 4) Add Environment variables for GIT as above complete path.

Also, go to global security settings -> Enable Slave -> Master.

This should work.

Cheers, Ashoka.

Update your system environment variables with your Git\\bin path.

Then update your Jenkins Slave's node properties with Tool Location .

List of tool locations

Name    Git(Default)

Home    your git.exe directory path (Git\bin\git.exe)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM