Mat*_*kas 6 git npm gitlab gitlab-ci
我的.gitlab-ci.yml文件中有一份工作,其内容npm install如下:
test:
image: node:10
script:
- npm install
- npm test
Run Code Online (Sandbox Code Playgroud)
问题是我要在我的私有GitLab存储库中引用它package.json:
"dependencies": {
"internal-dep": "git+https://gitlab.com/Company/internal-dep.git",
...
Run Code Online (Sandbox Code Playgroud)
该npm install命令在本地工作,因为我已经针对GitLab进行了身份验证,但是在GitLab CI上失败。如何internal-dep在GitLab CI上成功解决问题?
我发现有两种方法可以使Git在该npm install步骤中针对GitLab成功进行身份验证(该方法在后台使用Git访问此依赖项)。
第一种方法,如本.gitlab-ci.yml工作所示:
test:
image: node:10
script:
- echo -e "machine gitlab.com\nlogin gitlab-ci-token\npassword ${CI_JOB_TOKEN}" > ~/.netrc
- npm install
- npm test
Run Code Online (Sandbox Code Playgroud)
第二种方法似乎也可行:
test:
image: node:10
script:
- git config --global url."https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/".insteadOf https://gitlab.com/
- npm install
- npm test
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
619 次 |
| 最近记录: |