Write GitLab CI variables to file

Viewed 4940

How could I write GitLab CI variables to config file like this:

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

The variables couldn't be resolved. Always I get the following json in file config.json: {"database":"$DB_NAME"} but I want this {"database":"my_database_name"}

How could I solve this problem?

1 Answers

I solved my problem via shell script with parameters like this:

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
Related