Environment variable in command

Below will return error,how to use environment variable ${DRONE_DEPLOY_TO} with commands together?

  - name: build
    image: node:12-alpine
    commands:
      - yarn build:${DRONE_DEPLOY_TO}

You should use the double dollar signs when you want the command to be interpreted by the shell, and not by the YAML processor:

  - name: build
    image: node:12-alpine
    commands:
      - yarn build:$${DRONE_DEPLOY_TO}
2 Likes