What is the best way to change application configurations in a CI environment

我与影子孤独终老i 提交于 2019-11-29 18:05:38

Some approaches:

Properties using Advanced Platforms

Use some web platform like :

With this approaches , when a change of configurations is required, you just need update the value in the system and restart your application. It is even possible a hot reload in java applications.

Properties from Environment variables

You can export your key:value properties as environment vars before starting the application :

export DATABASE_HOST=10.100.200.300
export LOG_DIR_LOCATION=/logs

And read it after after the application has started:

Java >> System.getEnv("DATABASE_HOST"); 
node.js >> process.evn.LOG_DIR_LOCATION
php >> getenv('DATABASE_HOST')

Properties from SCM

  • Create some svn repositoty called development-configurations
  • Upload your database.xml with development values
  • In your application, put a database.xml with dummy values : localhost, etc
  • Create a jenkins job and put the environment as an argument.
  • In the same job download svn source code of your application.
  • download svn repository called $environment-configurations. $environment will be your argument
  • replace the database.xml inside of your application with database.xml of $environment-configurations repository.
  • Just create another repositories for testing, uat and production. Job must be receive environment as an argument to choose the right database.xml

Properties from Database

Modify your applications to read configurations from some database instead of xml file

Properties from File System

Modify your application to read an external database.xml instead of the database.xml inside of your source code. With this approach you just need put the database.xml in some path of your server and delete it from your application source code.

Note

You can use these approaches not only for backend apps. You can use them for frontends applications:

Devops Variable Substitution for Frontend js applications

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