Here is my scenario:
I have configured two Git installations as indicated in Jenkins path to git Windows master / Linux slave . Git installations are set up as follows:
WindowsGit
| Path: C:\\Program Files\\Git\\bin\\git.exe
LinuxGit
| Path: /usr/local/bin/git
Because I need to run the job on linux slave, my job git configuration is pointing to LinuxGit (Git executable option). Job runs great, no problems. However, when I try to use "Poll SCM" option, it breaks. I believe the problem here is because Poll SCM runs on the Windows Master and the Git information for this job is pointing to LinuxGit. Git Polling Log shows:
Caused by: java.io.IOException: Cannot run program "/usr/local/bin/git": CreateProcess error=2, The system cannot find the file specified
In the other hand, if I select WindowsGit, Git Polling Log is fine but job itself will obviously fail because it's running on a Linux Slave.
Question: Can anyone think about a way I can select one Git installation for the Source Code Management configuration and another one for the Poll SCM feature?
As requested, I'm posting my own answer to the general idea, for mixing Windows/Linux on Master Slaves when working with git. This solution will allow even to run the same job on multiple mix of Windows/Linux slaves as well as won't break Master polling scm:
Whatever you Jenkins Master platform is, configure the default git installation to point to a valid git for that platform. For example, c:\\apps\\git\\bin\\git.exe
for Windows. and then configure the custom " Tool Locations " for each node. This way the master will be able to poll git to check for changes and trigger the job on a slave. The Slave will then be capable to clone the git code because it has its custom location for (Git) Default . Steps to configure properly:
/usr/local/bin/git
) Node configuration for the linux slave node should look something like this:
I believe the additional "git installations" are more suitable, as @Jayan mentioned, when you need to have multiple git installations or you need to run, for some reason, a specific version of git for select Jenkins jobs.
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.