Variable name substitution undefined in cloud build gcp

212 Views Asked by At

Hi all I have an issue which I am unable to proceed. According to the user guide, it mentioned that $REPO_NAME is supposed to be substitute to the repository name checked out.

An example the repository that is being check out is DEMO

I would like to create in the workspace a folder name DEMO.

When I use the code snippet below it will output as

— workspace
  — $REPO_NAME

my expectations is

- workspace
  - DEMO

steps:
- name: 'ubuntu'
  id: 'prerequisite'
  script: |
    #!/usr/bin/env bash
    mkdir /tmp/$REPO_NAME
    mv -v * /tmp/$REPO_NAME/
    cp -r /tmp/$REPO_NAME /workspace/
    ls -ltr

is there a way that I can use these variable throughout?

1

There are 1 best solutions below

1
Christophe Kalt On

Per https://cloud.google.com/build/docs/configuring-builds/substitute-variable-values#mapping_substitutions_to_environment_variables

Scripts don't directly support substitutions, but they support environment variables. You can map substitutions to environment variables, either automatically all at once, or manually by defining every environment variable yourself.

Have you set automapSubstitutions?