Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 766
BestPractices Avatar asked Sep 04 '12 14:09

BestPractices


People also ask

How does Jenkins deploy code to multiple servers?

You can deploy to multiple servers using the Node and Label parameter plugin. Add the servers you want to deploy your code using Jenkins nodes: Manage Jenkins > Manage nodes > New node. Be sure to add a label to each node so you can group them together and deploy to that group.

Can Jenkins can be run from external Web server?

A Jenkins server available on the public Internet and configured with Git, Maven, Notification plugin, and Build Authorization Token Root plugin. You would also need the Admin privileges of the Jenkins server to install the plugins, if they are not already installed. Note: This tutorial is created using Jenkins ver.

How do you call a Jenkins build from outside Jenkins?

Create a remote Jenkins build trigger in three stepsCreate a Jenkins build job and enable the Trigger builds remotely checkbox. Provide an authentication token; This can be any text string of your choice. Invoke the Jenkins build URL to remotely trigger the build job.


1 Answers

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.

like image 191
Gonen Avatar answered Nov 11 '22 13:11

Gonen