Connecting Jenkins on Windows to Git

Setting up connection from Jenkins/Hudson to your Git server shouldn’t be any problem if the CI server is running on Linux, but achieving the same from Windows seems to be little trickier. The problem I encountered was that any build I tried to execute hang forever right on the start trying to obtain sources from the repository.
Googling around I found some suggestions to run Jenkins server on a dedicated user account and put private SSH key into proper directory. Unfortunately, that didn’t work. Without going into more details I’d just recommend you to keep Jenkins running as a service by the system user.
Assuming that Jenkins has the Git plugin properly installed and your build is configured, there are two key things that you need to do:


This file contains fingerprints of external ssh hosts. Each entry means a “trusted” host. Without it, ssh shows a warning during connection and prompts you for action, which exactly the reason why Jenkins build hangs on connection to Git server.

To create such file you can, for example, execute “ssh targethost” in your console (or connect using putty), answer “yes” and get known_hosts from your home/.ssh Next, put it in your Git client’s .ssh subdirectory (create one if necessary). In my case it was:

C:\Program Files (x86)\Git\.ssh\known_hosts

Private ssh key

I assume that you already know how to generate a pair of RSA public/private key and the public key to your Git server configuration. The important thing that you need to do in order to make the pair work properly for Jenkins is, similarly to known_hosts, to put your private key in Git .ssh subdirectory and name it “id_rsa”:

C:\Program Files (x86)\Git\.ssh\id_rsa

Voilà. Try now to execute your build, it should download sources.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s