I have a Windows 7 and a Windows Server 2012 slave with the Jenkins agent and Cygwin already set up. I want to avoid Cygwin and just use the Git Bash shell that comes with Git f
I've worked it out. Jenkins will simply pick the first sh.exe in the path. Git Bash has an exe at C:\Program Files\Git\usr\bin
, so if you add that to the beginning of your path it will be picked up by Jenkins.
You have to restart your slave's connection with Jenkins after making this change, otherwise the Path won't propagate. If you're using the Java Web Start, just close the java window and relaunch it.
If you have only Windows agents and they all the have Git for Windows installed to the same location you can set the shell executable for all agents in the Jenkins System Configuration.
Go to Manage Jenkins > Configure System, scroll down to Shell and set the Shell executable to point to whatever shell you want to start with the Execute shell build step.
Here's an example how to set the shell which is installed with Git for Windows:
Note: This won't work if you have a mixture of Windows and non-Windows agents (JENKINS-38211). It will cause similar issues if you have Windows agents where sh.exe
is installed to different locations (such as a mixture of 32-bit and 64-bit Windows using the default install location for those platforms). Use this only when your environment contains only identically configured Windows nodes.
Install git-bash
Ensure the Git\bin folder (i.e.: C:\Program Files\Git\bin) is in the global search path, in order for Jenkins to find sh.exe
to update path in windows use following command
setx path "%path%;C:\Program Files\Git\bin"
or have a look here https://www.windows-commandline.com/set-path-command-line/
to make nohup available for Jenkins
mklink "C:\Program Files\Git\bin\nohup.exe" "C:\Program Files\git\usr\bin\nohup.exe"
mklink "C:\Program Files\Git\bin\msys-2.0.dll" "C:\Program Files\git\usr\bin\msys-2.0.dll"
mklink "C:\Program Files\Git\bin\msys-iconv-2.dll" "C:\Program Files\git\usr\bin\msys-iconv-2.dll"
mklink "C:\Program Files\Git\bin\msys-intl-8.dll" "C:\Program Files\git\usr\bin\msys-intl-8.dll"
That's it now you can run shell commands
Have fun