配置哈德森/詹金斯分期和生产 [英] Configuring Hudson/Jenkins for staging and production

查看:133
本文介绍了配置哈德森/詹金斯分期和生产的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么配置哈德森/詹金斯生产及分期部署配置相同的?

How do I configure Hudson/Jenkins to production and staging deploy with the same configuration?

我有一个构建和部署工作流程配置詹金斯做生产推送。现在我需要使用相同的配置做了升级推动,预计情侣文件夹和放大器; DB名称将改变,以反映阶段。即比如从的/ var /生产/ HTML 的/ var /期/ HTML 和db从 companyname_table companyname_table_stage

I have a build and deploy workflow configured in Jenkins to do production pushes. Now I need to use the same configuration to do a staging push, expect that couple of folder & DB names will change to reflect stage. I.e. Say from /var/prod/html to /var/stage/html and db from companyname_table to companyname_table_stage.

我不想做配置的副本,因为我可能要在一个地方更改的配置那么我将不得不做出的每一个副本,副本的变化。理想的情况是我想通过传递一些参数来尝试这种

I don’t want to do a copy of the configuration since I may have to change the configuration in one place then I will have to make duplicate changes to every copy. Ideally I want to attempt this by passing some parameter

推荐答案

您可以配置项目以参数化,并添加参数,指定在哪里部署(即分期或生产)。你如何做到这一点取决于你使用的构建系统。例如。如果您使用的蚂蚁,该参数将被暴露成一个环境变量,所以你可以只是一个变量表示其是否分期与生产,然后在ant脚本中,您需要设置属性为的/ var /督促/ HTML companyname_table 的/ var /期/ HTML companyname_table_stage 根据该参数是什么。

You could configure the project to be parameterized, and add a parameter specifying where to deploy to (i.e. staging or production). How you do this depends on what build system you are using. E.g. if you are using ant, the parameter will be exposed as an environment variable, so you could just have one variable saying whether its staging vs production, and then within the ant script you would set properties to /var/prod/html and companyname_table or /var/stage/html and companyname_table_stage depending on what that parameter is.

如果由于某种原因,你必须建立一个不能改变的基础上的参数属性值逻辑,你会需要不同的值不同的参数(如db表一个参数以及用于在HTML位置的一个参数)

If for some reason you have build logic that couldn't change the property value based on the parameter, you would need separate parameters for the different values (e.g. one parameter for the db table and one parameter for the html location)

如果你需要单独项目分期VS部署,然后你可以有一个项目的结构是这样的:

If you need separate projects for staging vs deploying, you could then have a project structure like this:

项目X:包含所有的配置和构建/部署的逻辑
二期工程-X:触发项目X的参数化建设,设置为临时值的参数
项目部署-X:触发项目X的参数身材,集生产值的参数

Project X: contains all the configuration and build/deploy logic Project Stage-X: triggers a parameterized build of Project X, with the parameter set to the staging value Project Deploy-X: triggers a parameterized build of Project X, with the parameter set to the production value

这也具有这样的优点,它很容易增加附加分段服务器或部署配置,其刚刚改变这些参数值中的一个问题。

This also has the advantage that it is easy to add additional staging servers or deployment configurations, its just a matter of changing those parameter values.

这篇关于配置哈德森/詹金斯分期和生产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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