Jenkins: How to make single job build and deploy on two servers

javaMan picture javaMan · Feb 22, 2013 · Viewed 25.7k times · Source

I have code in a repository. Now I want to create a job which will build code from the repository and deploy it on two servers.

Right now I create two jobs with exactly the same configuration. The only change is the server on which it needs to deploy.

Is it possible to do this with single job?

Answer

vikingsteve picture vikingsteve · Feb 22, 2013

Can I suggest to use this maven plugin. You can configure batch tasks (either maven goals, or scripts) that you can attach to your normal maven jobs.

https://wiki.jenkins-ci.org/display/JENKINS/Batch+Task+Plugin

Firstly, you have a Jenkins job that builds your job normally.

Then, using this plugin, you can configure two extra tasks on that same Jenkins job called, say, "Deploy-server-1" and "Deploy-server-2".

After you build your job, click on the "Task" button and you can easily run your deploy tasks.

So the process is:

-> build
     -> deploy server 1
     -> deploy server 2

If you have a look on the link I added for the Batch Tash Plugin, they have a single task called 'release'. Just imagine you can have more tasks right under it, to do whatever you want.

You probably need admin rights on your Jenkins server in order to install this plugin, if it's not there already...