title: How to include CI_JOB_TOKEN in Dockerfile on gitlab?
body: <p>I'm having an issue where I seem to be struggling to pass the <code>CI_JOB_TOKEN</code> around my CI/CD flow so that I can download private gitlab npm modules from my <code>Dockerfile</code>.</p>
  
  <p>my files look like this:</p>
  
  <p><strong>gitlab-ci.yml</strong></p>
  
  <pre><code>image: tmaier/docker-compose:latest
    variables:
      CI_JOB_TOKEN: ${CI_JOB_TOKEN}
  ​
  stages:
    - build
  ​
  build:
    stage: build
    script:
      - docker-compose build --build-arg CI_JOB_TOKEN=${CI_JOB_TOKEN}
      - docker-compose push --arg CI_JOB_TOKEN=${CI_JOB_TOKEN}
  </code></pre>
  
  <p>​
  <strong>docker-compose.yml</strong></p>
  
  <pre><code>services:
    qa-service:
      build:
        context: .
        args:
          PORT: 3000
          CI_JOB_TOKEN: ${CI_JOB_TOKEN}
  </code></pre>
  
  <p>​
  <strong>Dockerfile</strong></p>
  
  <pre><code>FROM ubuntu:latest
  ​
  ARG CI_JOB_TOKEN
  RUN npm install \
      "git+https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.example.com/xxx/yyy.git"
  </code></pre>
  
  <p>I keep getting this error </p>
  
  <blockquote>
    <p>npm ERR! Error while executing: </p>
    
    <p>npm ERR! /usr/bin/git ls-remote -h -t <a href="https://gitlab-ci-token:%24%7BCI_JOB_TOKEN%7D@gitlab.example.com/xxx/yyy.git" rel="noreferrer">https://gitlab-ci-token:%24%7BCI_JOB_TOKEN%7D@gitlab.example.com/xxx/yyy.git</a></p>
    
    <p>npm ERR!  </p>
    
    <p>npm ERR! remote: HTTP Basic: Access denied </p>
    
    <p>npm ERR! fatal: Authentication failed for '<a href="https://gitlab-ci-token:%24%7BCI_JOB_TOKEN%7D@gitlab.example.com/xxx/yyy.git/" rel="noreferrer">https://gitlab-ci-token:%24%7BCI_JOB_TOKEN%7D@gitlab.example.com/xxx/yyy.git/</a>'</p>
    
    <p>npm ERR!  </p>
    
    <p>npm ERR! exited with error code: 128</p>
  </blockquote>