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

前端 未结 6 881
刺人心
刺人心 2021-02-06 15:37

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

6条回答
  •  天命终不由人
    2021-02-06 15:55

    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...

提交回复
热议问题