Docs
我正在尝试在conainter_commands
条目中传递多个命令并不断收到错误。然而,当我传递与单个条目相同的命令时,它工作正常。
工程:
container_commands:
01_remove_old_dump:
command: 'rm -f /tmp/db.dump'
02_get_new_dump:
command: 'aws s3 cp s3://bucket/db.dump'
失败并显示/bin/sh: rm -f /tmp/db.dump: No such file or directory.
container_commands:
01_remove_old_dump:
command: ('rm -f /tmp/db.dump' 'aws s3 cp s3://bucket/db.dump')
没
关系,我只是用 YAML 块打破了行,这有效:
01_command:
command: |
if [[ ! $ENVIRONMENT = "PROD" ]] && [[ $RDS_HOSTNAME ]]
rm -f /tmp/db.dump
aws s3 cp s3://bucket/db.dump
pg_restore -H $RDS_HOSTNAME dbname /tmp/db.dump
echo "Refreshing database..."
else
Echo "Environment is ${ENVIRONMENT}. Skipping database refresh..."
fi
注意:删除了这个,它似乎不起作用(总是返回 true):
test: |
[[ ! $ENVIRONMENT = "PRODUCTION" ]] &&
[[ $RDS_HOSTNAME ]] &&
echo "Refreshing database..."