Search code examples
deploymentjenkinsmaster-slaveartifacts

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


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?


Solution

  • This is basic "Client - Server" behavior in Jenkins -
    see Managing Jenkins > Managing Nodes for that.

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

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

    C) Set step '4.' in your example to run on the remote Agent (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 server-machine.