7

文档

我试图在一个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')
4

1 回答 1

10

没关系,我只是用 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..."
于 2016-06-04T02:58:38.493 回答