I'm having an issue where I seem to be struggling to pass the CI_JOB_TOKEN
around my CI/CD flow so that I can download private gitlab npm modules from my Dockerfile
.
my files look like this:
gitlab-ci.yml
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}
docker-compose.yml
services:
qa-service:
build:
context: .
args:
PORT: 3000
CI_JOB_TOKEN: ${CI_JOB_TOKEN}
Dockerfile
FROM ubuntu:latest
ARG CI_JOB_TOKEN
RUN npm install \
"git+https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.example.com/xxx/yyy.git"
I keep getting this error
npm ERR! Error while executing:
npm ERR! /usr/bin/git ls-remote -h -t https://gitlab-ci-token:%24%7BCI_JOB_TOKEN%7D@gitlab.example.com/xxx/yyy.git
npm ERR!
npm ERR! remote: HTTP Basic: Access denied
npm ERR! fatal: Authentication failed for 'https://gitlab-ci-token:%24%7BCI_JOB_TOKEN%7D@gitlab.example.com/xxx/yyy.git/'
npm ERR!
npm ERR! exited with error code: 128