Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Automatically mapping substitutions to environment vars when calling external scripts

I have this step that calls a shell script as an argument:

 

- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk:${_CLOUD_SDK_VERSION}'
    id: 'deploy_image_to_cloud_run'
    entrypoint: 'bash'
    args: ['scripts/deploy.sh']
    automapSubstitutions: true # Map substitutions to environment variables

 

I can't seem to reference any of the user-defined or built-in  substitutions from the deployment script. Here's an example if statement where I try to match the $_DEPLOY_MODE substitution:

 

if [[ "$_DEPLOY_MODE" == "PREVIEW" ]]; then
  echo "Deploying preview build with 0% traffic"
elif [[ "$_DEPLOY_MODE" == "PUBLIC" ]]; then
  echo "Deploying latest build with 100% traffic"
else
  echo "Unknown deploy mode: $_DEPLOY_MODE"
  exit 1
fi

 

Here's the build output from the above example:

 

1_DEPLOY_MODE # Output of an echo statement for debugging purposes
Unknown deploy mode: 1_DEPLOY_MODE

 

What gives? Does the `automapSubstitutions` field even work when calling external scripts?

0 0 63
0 REPLIES 0