###常量分类
- 应用常量(application-specific constant)
MAX_LENGTH = 100- etc.
- 环境常量(environment-specific constant)
DB_HOST = localhost- etc...
- development(local machine)
- host: 172.16.xxx.xxx
- db: localhost
- pwd: 123456
- staging(staging server)
- host: 10.60.xxx.xxx
- db: dbstage
- pwd: xxxxxx
- production(production cluster)
- host: xxx.xxx.xxx.xxx
- db: dbprod
- pwd: *****
process.env属性返回包含用户环境的对象可以修改此对象,但这些修改不会反映到 Node.js 进程之外
Dotenv is a zero-dependency module that loads environment variables from a
.envfile intoprocess.env
dotenv 定义的环境变量对于项目而言是环境常量,会覆盖 bash(执行环境)中的环境环境变量
由于同一项目不同人员之间开发机器不尽相同,需要在 .env 文件中定义的环境变量不同,推荐的做法是提供 .env.example 文件解释项目需要什么环境变量并由开发人员手动复制替换环境变量(需忽略 .env 文件的版本跟踪)
Predefined environment variables reference
variables:
TEST: "HELLO WORLD"在Settings > CI/CD 中添加键值对
- Trigger variables or scheduled pipeline variables.
- Project-level variables or protected variables.
- Group-level variables or protected variables.
- YAML-defined job-level variables.
- YAML-defined global variables.
- Deployment variables.
- Predefined environment variables.