But it couldn't be so simple. As usual. It appears that Git uses specific authorization by means public keys. Well, it doesn't make a problem if you are going to run Git locally from command line. But I was going to involve Hudson to get sources from Git and it made some specifics. No matter what's the user you're logged on the Hudson uses SYSTEM user and default SSH key doesn't work there. As the result, you get errors like:
$ git clone -o origin git@hostname:/home/git/repositories/project.git "e:\HUDSON_HOME\jobs\Project Trunk\workspace" ERROR: Error cloning remote repo 'origin' : Could not clone git@hostname:/home/git/repositories/project.git ERROR: Cause: Error performing git clone -o origin git@hostname:/home/git/repositories/project.git e:\HUDSON_HOME\jobs\Project Trunk\workspace Trying next repository ERROR: Could not clone from a repository FATAL: Could not clone hudson.plugins.git.GitException: Could not clone
And even worse. Actually build hangs because Git asks for password and input is not accessible. So, the above error is normally seen after build interruption.
Well, it's actually known issue and it can be found here. Luckily there was a resolution described in this issue. Key idea is that we have to make some batch file with command line like:
plink -i /path/to/private/key %*
and after that we should set the path to batch file as GIT_SSH environment variable value. No problem. At least before you get back to Hudson and start running again just for several reasons. Firstly, plink utility should be available (no problem since we can easily install it) and secondly, don't forget that Hudson user and logged user are still different.
So, my adventures weren't finished with that. This time I've seen that key was picked up but now Git asked to confirm that this host is trusted one. Well, it couldn't make any problem if the run were done via command line window. But once again it appears during execution within Hudson and there were no ability to enter anything there.
Fail. Once again. Though, even such results were a good progress (better than nothing, you know). I've found several recommendations to avoid this problem but only one of them worked.
Actually, Hudson can be installed as a service and we can tune it to run under logged user. For Windows it's done by selecting Start > Control Panel > Administrative Tools > Services. After that we can easily find our Hudson service and change logon user in it's properties (LogOn tab).
And finally that's it. Hudson now shows the same behavior as I run the same commands from command line window. Finally it works.
The only thing left is to link all resources to run them all together. But that's completely different story.
P.S.: I hope that's the only surprise from Git and all further things will be better
No comments:
Post a Comment