views:

77

answers:

3

What is the simplest way to schedule a batch file to run on a remote machine using Hudson (latest and greatest version)? I was exploring the master slave setup. I created a dumb slave but I am not sure what the parameters should be so that I can trigger the batch file in the remote slave machine.

Basically, I am trying to run 2 different batch files on two different remote machines sequentially, triggered from my machine (the master). The Step by step guide on the Hudson website is a dead link. There are similar questions posted on SO but it does not quite work for me when I use the parameters they mention. If anyone has done something similar please suggest ways to make this work. (I know how to set up jobs, and add a step to run a batch file etc what I am having trouble configuring is doing this on a remote machine using hudson in built features)

UPDATE

Thank you all for the suggestions. Quick update on this: What I wanted to get done is partially working, below are the steps followed to get to it -

  1. Created new Node from Manage Nodes -> New Node -> set # of Executors as 1, Remote FS root set as '/var/hudson', set Launch method as using JNLP, set slavename and saved.

  2. Once slave was set up (from master machine), I logged into the Slave physical machine, I downloaded the _slave.jar from http://masterserver:port/jnlpJars/slave.jar, and ran the following from command line at the download location -> java -jar _slave.jar -jnlpUrl http://masterserver:port/computer/slavename/slave-agent.jnlp. The connection was made successfully.

  3. Checked 'Restrict where this project can be run' in the Master job configuration, and set paramater as slavename.

  4. Checked "Add Build Step" for adding my batch job script

  5. What I am still missing now is a way to connect to 2 slaves from one job in sequence, is that possible?

+1  A: 

I had some similar trouble with slave setup and wrote up this blog post - I was running on Linux rather than Windows, but hopefully this will help.

gareth_bowles
Thanks for writing up your blog Gareth, it did help. In the end what made it work was the 'Restrict where this project can be run' configuration.
sjt
A: 

I dont know about how to use built-in hudson features for this job - but in one of my project builds, i run a batch file that in turn uses PSTools to run the job on a remote server. I found PS tools extremely easy to use - download, unpack and run the command with the right parameters, hence opted to use this.

Critical Skill
+1  A: 

It is fairly easy and straight forward. Lets assume you already have a slave running. Then you configure the job as if you are locally on the target box. The setting for Restrict where this project can be run needs to be the node that you want to on. This is all for the job configuration.

For the slave configuration read the following pages.

  1. Installing Hudson as a Windows service
  2. Distributed builds

On windows I prefer to run the slave as a service and let the remote machine manage the start up and shut down of the slave. The only disadvantage with this is, you need to upgrade the client every time you update the server Just get the new client.jar from the server, after the upgrade and put it on the slave. Then restart the slave and you are done.

I had troubles using the install as a service option for the slave even though I did it as a local administrator. I used then srvany to wrap the jar into a service. Here is a blog about it. The command that you need to wrap, you will get from your Hudson server from the slave page. For all of this to work, you should set up the slave management as jnlp.

If you have an ssh server on your target machine, you can use the ssl slave settings. These work for me like a charm. I use them with my unix slaves. So far the ssl option with unix is less of an hassle, than the windows service clients.

Peter Schuetze
Thanks Peter. You are right, it went smoother than I thought. The 'Restrict where this project can be run' worked great. Do you know if I can have 2 slaves configured from one job, and running stuff sequentially on them?
sjt
Haven't found a solution for this yet. The only way is to open a connection from your local system to the remote system 'manually' within the job (e.g. Windows comes with a telnet server, but you need a non-interactive telnet client.) It would be better to use ssh because of security. If you use ssh, you can use the ssh plugin, which will give you pre- and post build steps. http://wiki.hudson-ci.org/display/HUDSON/SSH+plugin
Peter Schuetze