gpt4 book ai didi

php - 将 GitLab CI 变量写入文件

转载 作者:行者123 更新时间:2023-12-04 15:23:02 28 4
gpt4 key购买 nike

我怎样才能像这样将 GitLab CI 变量写入配置文件:

test:
stage: test
script:
- touch "config.json"
- echo "{"database":"$DB_NAME"}" >> config.json

无法解析变量。我总是在文件 config.json 中得到以下 json:{"database":"$DB_NAME"} 但我想要这个 {"database":"my_database_name "

我该如何解决这个问题?

最佳答案

我通过带有如下参数的 shell 脚本解决了我的问题:

test:
stage: test
script:
- bash setup_config_for_tests.sh $DB_NAME $DB_PASSWORD $SALT $HOST_PROD $USERNAME_PROD $PASSWORD_PROD
#!/bin/bash

# create config file
touch "config.json"

# write config json to config file
echo "{\"param1\": \"${1}\"}" >> config.json

关于php - 将 GitLab CI 变量写入文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62904062/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com