title: How to pass substitution variables on Google Cloud build to run a dockerfile
body: <p>I have set up a Github trigger on Google Cloud build. I already have a dockerfile to do the build steps. Since there is no provision to pass substitution variables I am trying to build it with cloud build configuration file (yaml) and then passing the path to the dockerfile in the configuration file.</p>
  <p>This is the cloud build configuration file where I need to pass 5 variables for the Dockerfile to consume and the yaml file goes like this:</p>
  <pre><code>steps:
  - name: 'gcr.io/cloud-builders/docker'
    env:
    - 'ACCESS_TOKEN=$ACCESS_TOKEN'
    - 'BRANCH=$BRANCH'
    - 'UTIL_BRANCH=$UTIL_BRANCH'
    - 'ARG_ENVIRONMENT=$ARG_ENVIRONMENT'
    - 'ARG_PYTHON_SCRIPT=$ARG_PYTHON_SCRIPT'
    args:
    - build
    - &quot;--tag=gcr.io/$PROJECT_ID/quickstart-image&quot;
    - &quot;--file=./twitter/dax/processing_scripts/Dockerfile&quot;
    - .
  </code></pre>
  <p>When the trigger runs the build, I get an error in one of the build steps in dockerfile saying that the variable is not available. It's clear that the environment variable passed in the yaml file is not being passed to the Dockerfile for consumption.
  And this is how the I have filled the substitution variables in on the trigger page
  <a href="https://i.stack.imgur.com/Q5w8B.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Q5w8B.png" alt="enter image description here" /></a></p>
  <p>Pasting the build code from step 5 where the error occurs, before which is just apt-get update commands running:</p>
  <pre><code>Step 5/28 : RUN git config --global url.&quot;https://${ACCESS_TOKEN}:@github.com/&quot;.insteadOf &quot;https://github.com/&quot; &amp;&amp; echo $(ACCESS_TOKEN)
   ---&gt; Running in f7b94bc2a0d9
  
  /bin/sh: 1: ACCESS_TOKEN: not found
  Removing intermediate container f7b94bc2a0d9
   ---&gt; 30965207dcec
  Step 6/28 : ARG BRANCH
   ---&gt; Running in 93e36589ac48
  Removing intermediate container 93e36589ac48
   ---&gt; 1d1508b1c1d9
  Step 7/28 : RUN git clone https://github.com/my_repo45/twitter.git -b &quot;${BRANCH}&quot;
   ---&gt; Running in fbeb93dbb113
  Cloning into 'twitter'...
  remote: Repository not found.
  fatal: Authentication failed for 'https://github.com/my_repo45/twitter.git/'
  The command '/bin/sh -c git clone https://github.com/my_repo45/twitter.git -b &quot;${BRANCH}&quot;' returned a non-zero code: 128
  ERROR
  ERROR: build step 0 &quot;gcr.io/cloud-builders/docker&quot; failed: step exited with non-zero status: 128```
  
  Could anyone please point out what the issue and validate if the environment declaration is proper?
  </code></pre>