Jenkins and Git on Windows

  • Post author:
  • Post category:Java / Tools

We recently set up an old Windows XP machine as our Jenkins CI server. Here are the steps we took to make it work.

1. Download and install Jenkins. Here we are going to install the Windows native package.

2. Since Jenkins runs on port 8080 by default and we want this port to be open for other Tomcat instances, edit <JENKINS-HOME>jenkins.xml and change –httpPort=8080 to –httpPort=8081. Also change the AJP port by adding –ajp13Port=8010.

3. Since we have environment variables already setup on User Account, we will change the Jenkins service to use our User Account instead of the default Local System. Change this in Control Panel -> Services. Restart the Jenkins service when prompted.

4. Use Pageant to cache your SSH key passphrase. This is discussed more at the end of this post. You can also temporarily remove the passphrase by running ssh-keygen -p and add it back once you get everything working.

5. To prevent the Git Plugin from hanging, make sure things work via command prompt first. Here we are using a Bitbucket repository. Run

git clone

If you see the message “The authenticity of host … can’t be established.”, say yes. This is a one time prompt as it will get saved into your known_hosts file. Be on the lookout for multiple known_hosts files in your system.

6. Install the Git Plugin. Go to Manage Jenkins -> Manage Plugins -> Available. Check the Git Plugin, then click “Download now and install after restart”. Click “Restart Jenkins when installation is complete and no jobs are running”

7. Configure Jenkins by going to Manage Jenkins -> Configure System. Set “Path to Git executable” to <GIT-HOME>cmdgit.cmd. Set JAVA_HOME or you can let Jenkins install one automatically. Set MAVEN_HOME or you can also let Jenkins install Maven automatically. You probably want to get notified when a build failure occurs to also setup “E-mail Notification”.

8. Create a new Job and then under Configure -> “Source Code Management”, select Git and set the “Repository URL”. Use SSH URL so we don’t get any interactive prompts. GitHub will look something like

Bitbucket will look something like.

Click “Poll SCM” and set it to the schedule you want, like @hourly for example. Also setup E-mail Notification.

9. Read the official Jenkins Git Plugin page for more information. It has a whole section about The Git Plugin and Windows. It also talks about how to use Pageant if you have a passphrase in your SSH key.