Jenkins:如何在两个服务器上构建和部署单个作业 [英] Jenkins: How to make single job build and deploy on two servers

查看:124
本文介绍了Jenkins:如何在两个服务器上构建和部署单个作业的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在存储库中有代码.现在,我想创建一个作业,该作业将从存储库中构建代码并将其部署在两台服务器上.

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?

推荐答案

我可以建议使用此Maven插件.您可以配置批处理任务(Maven目标或脚本),这些任务可以附加到常规Maven作业中.

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/批处理+任务+插件

首先,您有一个詹金斯(Jenkins)工作,可以正常建立您的工作.

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

然后,使用此插件,您可以在同一Jenkins作业上配置两个额外的任务,例如"Deploy-server-1"和"Deploy-server-2".

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.

因此过程是:

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

如果您查看我为Batch Tash插件添加的链接,它们将执行一个名为发布"的任务.试想一下,您可以在其中执行更多任务,以完成您想要的任何事情.

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.

如果尚未安装此插件,则可能需要在Jenkins服务器上具有管理员权限才能安装此插件...

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

这篇关于Jenkins:如何在两个服务器上构建和部署单个作业的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆