The basic idea
You have to install git and get it into the path of the user account running Jenkins. We’ll take advantage of Github for Windows’ installation of git to do this.
How I did it
- Ensure that the Jenkins service is running under an account that you can actually log into. We’ll refer to this as JenkinsServiceAccount from here on.
- Login to the box with the JenkinsServiceAccount.
- Install Github for Windows. When it’s finished, just close the app if it comes up.
- There’ll be a shortcut to Git Shell on the desktop, right click that and click Open File Location.
- In the folder that opens, you’ll see a file named shell.ps1. Open it in your favorite text editor.
- Find the line where $env:github_git is set. Mine was set to:
- You need to add three subfolders of that folder to the system PATH (via System Properties -> Environment Variables -> System Variables). What I added looks like this:
- Restart the Jenkins service and it should now be able to use git.
The path to PortableGit looks like it has a changeset in the folder name which means that if you update Github for Windows, that path might change. This is dumb, however, I don’t believe Github for Windows will update if you never open it. So, never open it.