Configuring Hudson/Jenkins for staging and production

巧了我就是萌 提交于 2019-12-06 08:28:24

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.

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)

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

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!