jenkins msysgit publickey

literally… how to waste half a day digging for help on the internet
… and solving thanks to an issue had long time ago

k, you need to have your damn windows project building via Jenkins…
…if you work on SVN things are pretty easy, since the SCM is handled via an SVN Java library: you get your Jenkins Service installed using the Java Web Start functionality provided by Jenkins, and after having your fight with Visual Studio Express 2008 (“call vcvarsall.bat x86” & set VCTOOLS, VCTOOLSINC, WINDOWSSDKDIR) and QT, you are ready to go

now, you decide it is time to move to git + public ssh key authentication… *pray* … loudly

you need msysgit & tortoisegit, install them but don’t install msysgit on its default path… put it in c:git or nothing will work if you have it under C:Program Files (x86) … the tool doesn’t love those nice spaces in the path… you’ll waste ur time fiddling with it

secondly… ensure you have c:gitbin in the general PATH, and not only c:gitcmd … despite of what you’ll find on forums, to me git.exe was working, while git.cmd was not… up to you

then… you need to tell msysgit who is going to handle the private ssh key… set an environment variable as GIT_SSH with “tortoiseplink.exe”, ensure you have the bin folder of the TortoiseGit project in your PATH

then you need to tell the system which ssh key to use… and here starts the pain… since git.exe and tortoiseplink.exe gets shipped with no debug logging, or barely NOTHING…

I suggest you have a dedicated user to the Jenkins’ activities… named “jenkins” for example. Try to checkout the project via the UI integrated in Explorer by TortoiseGIT, just to be sure the keys are ok, and the git server is reachable. Taken that out of the equation… open up a cmd console and do the same commands by hand… git clone git://whatever … git pull… git status … all ok? I doubt…

At this stage, you realise that you have no way to specify the ssh key, the only way is to install “pageant” from the Putty project… u add the key to it, as ur beloved ssh-agent, and you think you are done… WRONG!
Jenkins won’t be able to use it… you think that forcing the service to run with “jenkins” credentials would solve… WRONG! it won’t see or have the scope to see the “pageant”, so you are back to ground zero…

…than I got the flash! Years ago I got nuts with Putty, cause it had somehow cached some options, like an ssh key, as default settings… At this stage I fired up Putty (I had to download it, only some components are coming down with TortoiseGit) and select the Default Profile, LOAD it… go to the ssh settings, select the key you’ve previously use (and converted with putty keygen) to be used with TortoiseGit, and SAVE

Stop “pageant” and try by command line all the git you did before… works? good… now try the same from Jenkins…. TADA!!!!!! Well done…

Advertisement

Leave a Reply

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

WordPress.com Logo

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

Facebook photo

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

Connecting to %s