【发布时间】:2018-05-24 13:59:36
【问题描述】:
我遇到了一个问题,我似乎很难在我的 CI/CD 流程中传递 CI_JOB_TOKEN,以便我可以从我的 Dockerfile 下载私有 gitlab npm 模块。
我的文件如下所示:
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"
我一直收到这个错误
npm 错误!执行时出错:
npm 错误! /usr/bin/git ls-remote -h -t https://gitlab-ci-token:%24%7BCI_JOB_TOKEN%7D@gitlab.example.com/xxx/yyy.git
npm 错误!
npm 错误!远程:HTTP 基本:访问被拒绝
npm 错误!致命:“https://gitlab-ci-token:%24%7BCI_JOB_TOKEN%7D@gitlab.example.com/xxx/yyy.git/”的身份验证失败
npm 错误!
npm 错误!退出错误代码:128
【问题讨论】:
标签: docker gitlab gitlab-ci-runner