How can I have Jenkins run a script on another server and watch over the result?

BestPractices picture BestPractices · Sep 4, 2012 · Viewed 11.5k times · Source

I want Jenkins to be able to kick off a deployment process on another server, but I want a process on that server to actually do the deplyoment process (for security reasons e.g. rather than having a user on the jenkins server ssh to the remote server and perform the deployment) and report the status of the deployment back to Jenkins.

It looks like the way to do this is to leverage Jenkins ability to have slave processes which can run on other servers, executing scripts and reporting console output, status, etc back to the master server.

So the sequence would be:

jenkins (master)

1. build ->

2. create artifacts ->

3. kick off deployment (using ssh kick off of slave job)jenkins (slave)

4. perform deployment ->

5. report status back to master jenkins server

Is this the appropriate way to achieve what I want to do?

Answer

Gonen picture Gonen · Sep 5, 2012

This is basic "Master - Slave" behavior in Jenkins - check the Distributed builds for that.

A) Install a Jenkins-slave on the remote machine.

B) Make this slave run "Tied Jobs" only.

C) Set step '4.' in your example to run on the remote Slave (or 'Node').

D) Step '3.' in your example should probably be a 'post-build-trigger' of step '2.'
(and not a step of its own).

The result of step '4.' in your example will be available to the master-machine.