tags:

views:

64

answers:

3

I am running hudson CI server on a win32 machine. After the build succeeds I want the exe created to be put on a public website. The hudon plugins for SCP and ftp were not working the way I wanted (mostly because it chooses some odd directories for where to place them) so I made my own script for a command line scp that hudson calls.

For some reason though when run under the hudson environment the scp bat file hangs. It works fine when I call it from a command line though on the same machine.

Apparently this also fails when run from the task scheduler.

Can anyone think of a reason this would not work from a hudson or scheduler environment?

pscp.exe -batch -q -pw mypassword ..\..\installers\Output\myfilename  [email protected]:domains/domain.com/html/downloads

(Note that 'domain.com' is a replacement for my domain name...)

Again, when I call that bat file from the command line it works just fine.

Note also - the reason I call a bat file is because I replace the filename with a svn WCREV command - since hudson is brain dead and can't do that replacement in either the scp or ftp plugins or on the command line calls. This method should work fin but it hangs.

pscp is a command line ssh program associated with Putty.

An additional issue I have is that this project access two svn repositories so hudson gets confused and can't provide the svn rev number at will in places where I expect it to be available. (One repo is for third party things and the other is our code base) We use the svn rev from our code base as part of the identifier to name the installer that is created.

I would be happy to use the ftp or scp from within hudson (The plugins) but they do not seem to work for me at all given the locations that hudson decides to put files (using build numbers - I do not want to use hudson's build numbers to identify builds - I prefer the svn revision) - thus I use the command line versions but those don't work either - they hang the hudson build process.

+2  A: 

Ran into the same issue myself. The problem is that pscp (like all of PuTTY) requires the hostkey for the server you're connecting to be loaded into the registry (in HKEY_CURRENT_USER). Without the hostkey, pscp will reject the host as invalid (there should be an error message that shows up in the console output unless you've surpressed it somehow. This is a one-time thing, but needs to be done for each user running the command.

This is the basic process I use:

  1. Connect to the server and port using PuTTY. Accept the hostkey when prompted.
  2. Run regedit.exe
  3. Browse to HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\SshHostKeys
  4. Export the relevant hostkey to a .reg file (right-click on SshHostKeys and select export)
  5. Login as the user Hudson runs as an import the exported .reg file

If Hudson is running as Local System, you can use PsExec or the technique described on this MSDN blog to run a command as the Local System account.

Once you've done this once, the command should work run under Hudson.

Edit

The two links just ways to run a command prompt as the Local System. You can tell what user id Hudson runs as by opening the Services control panel (services.msc) and finding the Hudson service and checking what it says under the Log On As column.

If it's not Local System, you should be able to login to Windows as the user and import the reg file. If it's run as Local System (the default) you can't login to Windows and need to use either PsExec or the technique described on the MSDN blog to import the registry file into the Local System's HKEY_CURRENT_USER tree.

ig0774
Thanks. That makes sense. I have suppressed the output - but I can look at it I guess. I run hudson runs as a service on this machine. I can't really seem to figure out how those two links you point out will help me.
Tim
@Tim see my edit above. Maybe that clarifies things?
ig0774
Hmm. I understood all that - I think my confusion is in the second link (I run as a service under local host). The url you posted does not seem to discuss anything about a registry... But maybe I am missing something.
Tim
@Tim: It doesn't. But running a command prompt will allow you to import the registry file. You could also take a look at WinSCP, which very mature.
ig0774
I must be stupid - how does that command prompt import the registry?
Tim
@Tim: You'd need to run a command to do it, something like "regedit /s hostkeys.reg"
ig0774
+1  A: 

How about upgrading your putty with Quest PuTTY. It is based on PuTTY and offers the parameter -auto_store_key_in_cache. This should solve your problem.

See also a similar question on SuperUser.

Peter Schuetze
thanks - I will look into that
Tim
What exactly do I do with PLink? I have a pscp command line that I use. Do I just use plink to create the key and then can use pscp or do I use plink instead of pscp?
Tim
plink = putty - GUI , that means you only have a command line where you can pass in your commands from file. Since you want to do file transfer you have to use scp. that comes with Quest version of putty. Quest PuTTY is an enhanced version of the latest PuTTY tools.
Peter Schuetze
A: 

I solved my problem by using an account that was able to runt he scp commands from the command line. Specifically, in the services configuration I set the hudson service to use another user that I had set up and not the system account.

This is not likely the best way to solve the problem, but it worked for me in the short-term.

Tim