Php 将GitLab CI变量写入文件
如何将GitLab CI变量写入如下配置文件:Php 将GitLab CI变量写入文件,php,continuous-integration,gitlab,yaml,gitlab-ci,Php,Continuous Integration,Gitlab,Yaml,Gitlab Ci,如何将GitLab CI变量写入如下配置文件: test: stage: test script: - touch "config.json" - echo "{"database":"$DB_NAME"}" >> config.json test: stage: test script: - bash setup_config_for_tests.sh $DB_
test:
stage: test
script:
- touch "config.json"
- echo "{"database":"$DB_NAME"}" >> config.json
test:
stage: test
script:
- bash setup_config_for_tests.sh $DB_NAME $DB_PASSWORD $SALT $HOST_PROD $USERNAME_PROD $PASSWORD_PROD
无法解析这些变量。我总是在文件config.json
中获得以下json:{“数据库”:“$DB_NAME”}
但是我想要这个{“数据库”:“我的数据库_NAME”}
我如何解决这个问题?我通过具有如下参数的shell脚本解决了我的问题:
test:
stage: test
script:
- touch "config.json"
- echo "{"database":"$DB_NAME"}" >> config.json
test:
stage: test
script:
- bash setup_config_for_tests.sh $DB_NAME $DB_PASSWORD $SALT $HOST_PROD $USERNAME_PROD $PASSWORD_PROD
#/bin/bash
#创建配置文件
触摸“config.json”
#将配置json写入配置文件
echo“{\”param1\”:\“${1}\”}>>config.json