I have to populate a parameters.yml file with variables in my pipeline. This is about 60 lines required in the file. So I tried using about 60 echo statements to populate the file, and keep it easily configurable, but when using the validator, it says my pipelines file is invalid because I need to use either a string or a pipe.
Is there another option that would let me echo a multi-line string to a file, or an other option to populate that file with environment variables?
This is how I tried it now:
pipelines:
default:
- step:
name: install and test
caches:
- composer
- node
- vendor
script:
- npm install
- npm install -g gulp
- echo "parameters:" > app/config/parameters.yml
- echo " database_driver: pdo_mysql" >> app/config/parameters.yml
- echo " database_host: $DB_HOST" >> app/config/parameters.yml
- echo " database_port: $DB_PORT" >> app/config/parameters.yml
- echo " database_name: $DB_NAME" >> app/config/parameters.yml
- echo " database_user: $DB_USER" >> app/config/parameters.yml
- echo " database_password: $DB_PASS" >> app/config/parameters.yml
- echo " redis.dsn.cache: \"$REDIS\"/0" >> app/config/parameters.yml
- echo " redis.dsn.doctrine: \"$REDIS/1\"" >> app/config/parameters.yml
- echo " redis.dsn.session: \"$REDIS/2\"" >> app/config/parameters.yml
- echo " mailer_transport: $MAIL_TRANSPORT" >> app/config/parameters.yml
- echo " mailer_host: $MAIL_HOST" >> app/config/parameters.yml
- echo " mailer_user: $MAIL_USER" >> app/config/parameters.yml
- echo " mailer_password: $MAIL_PASS" >> app/config/parameters.yml
- echo " mailer_port: $MAIL_PORT" >> app/config/parameters.yml
CodePudding user response:
I think the validator had some issues with me echo-ing yaml in the configuration. This is how I fixed it:
pipelines:
default:
- step:
name: install and test
caches:
- composer
- node
- vendor
script:
- npm install
- npm install -g gulp
- echo "parameters:" > app/config/parameters.yml
- echo " database_driver:\ pdo_mysql" >> app/config/parameters.yml
- echo " database_host:\ $DB_HOST" >> app/config/parameters.yml
- echo " database_port:\ $DB_PORT" >> app/config/parameters.yml
- echo " database_name:\ $DB_NAME" >> app/config/parameters.yml
- echo " database_user:\ $DB_USER" >> app/config/parameters.yml
- echo " database_password:\ $DB_PASS" >> app/config/parameters.yml
- echo " redis.dsn.cache:\ \"$REDIS/0\"" >> app/config/parameters.yml
- echo " redis.dsn.doctrine:\ \"$REDIS/1\"" >> app/config/parameters.yml
- echo " redis.dsn.session:\ \"$REDIS/2\"" >> app/config/parameters.yml
- echo " mailer_transport:\ $MAIL_TRANSPORT" >> app/config/parameters.yml
- echo " mailer_host:\ $MAIL_HOST" >> app/config/parameters.yml
- echo " mailer_user:\ $MAIL_USER" >> app/config/parameters.yml
- echo " mailer_password:\ $MAIL_PASS" >> app/config/parameters.yml
- echo " mailer_port:\ $MAIL_PORT" >> app/config/parameters.yml
- sed -i 's/\\ / /g' app/config/parameters.yml
Basically I couldn't echo valid yaml, so I fixed it using sed to modify the file so the yaml became valid.