Jenkins pipeline calls git.exe on non-windows node
I have a master set up on Windows machine.
I have a few nodes on Jenkins, one of which has 2 labels: "system project".
This node is actually a plain Solaris 11.3 machine.
Other nodes are plain windows machines (including master).
I have a Jenkinsfile in my project in which I defined pipeline as:
pipeline { agent { label 'system && project' } environment { PATH='$PATH:/home/user/path' } stage('Build') { echo "Test PATH=$PATH" }
...When I build, I see the error in the log appears:
ERROR: Error cloning remote repo 'origin'
...
Caused by: java.io.IOException: Cannot run program "git.exe" (in directory "/remote/rootdir/workspace/ProjectName"): error=2, No such file or directoryThe build is added as Jenkins Pipeline, not a freestyle project or something. And for now the only thing configured is GitLab repo with SSH credentials (rsa key).
But why does it try to call "git.exe" on Solaris? It clearly shows to me in the "Nodes" section () that it is, in fact, a SunOS (amd64).
Can it actually be called on the wrong Node? But I see the "/remote/rootdir/workspace/ProjectName" directory created (it wasn't there before, I even removed it and relaunched build to make sure Jenkins actually creates it). Clearly, this isn't the case, as I originally suspected.
The machine itself has git installed - I checked by manually cloning the same repo using the same rsa key.
What am I doing wrong? What am I missing? How to tell Jenkins to use correct git?
Please, help.
41 Answer
In this case the problem was that the jenkins master was installed and is running on windows and there wasn't any git configured for unix(solaris)/linux.
I had to go to Manage Jenkins >> Global Tools Configuration >> Git >> Add Git and add another instance of it with "Path to Git executable" equal to "git", pretty much like it is shown in the answer to this question: Jenkins could not run git
There was only one git configured: "Git-win"->"git.exe". Now there are two of them: "Git.win"->"git.exe" and "Git"->"git". And jenkins has an option in job configuration of which one to use. So you can select "Git-win" for windows jobs and "Git" for unix(solaris)/linux jobs.