我必須在我的管道中使用變數填充 parameters.yml 檔案。檔案中大約需要 60 行。所以我嘗試使用大約 60 個 echo 陳述句來填充檔案,并使其易于配置,但是在使用驗證器時,它說我的管道檔案無效,因為我需要使用字串或管道。
是否有另一種選擇可以讓我將多行字串回顯到檔案中,或者使用環境變數填充該檔案的其他選項?
這就是我現在嘗試的方式:
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
uj5u.com熱心網友回復:
我認為驗證器在配置中對我 echo-ing yaml 有一些問題。這是我修復它的方式:
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
基本上我無法回顯有效的 yaml,所以我使用 sed 修復它來修改檔案,以便 yaml 變得有效。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/368143.html
標籤:symfony 持续集成 持续部署 bitbucket-管道
上一篇:從選單中查找我所在的專案路線
