[英]Gitlab-ci is not using the node version I have specified
I'm very new to GitLab and am trying to set up the CI/CD system for my project. 我是GitLab的新手,正在尝试为我的项目设置CI / CD系统。
My .gitlab-ci.yml
file is as follows: 我的.gitlab-ci.yml
文件如下:
image: node:10.15.3
cache:
paths:
- node_modules/
before_script:
- node -v
- npm install
stages:
- test
all-tests:
stage: test
script:
- npm run lint
- npm run test:unit:cov
- npm run test:server
However the node -v
line outputs 6.12.0
not 10.15.3
and my tests are failing because the node version is wrong. 但是, node -v
行输出6.12.0
而不是10.15.3
并且我的测试失败了,因为节点版本错误。
How do I tell GitLab CI to use Node 10.15.3? 如何告诉GitLab CI使用Node 10.15.3?
You are not tagging your job so perhaps it is running on a shell-executor
and not a docker-executor
. 您没有标记您的工作,因此它可能是在shell-executor
而不是docker-executor
。 Check for .dockerenv
in your job spec to ensure you're running in a container; 在工作说明中检查.dockerenv
,以确保您在容器中运行;
Given this simple pipeline (based on yours): 鉴于这个简单的管道(基于您的管道):
image: node:10.15.3
before_script:
- node -v
stages:
- test
all-tests:
tags:
- docker
stage: test
script:
# are we in a docker-executor
- if [ -f /.dockerenv ]; then echo "docker-executor"; fi
I get the following output, which suggests we are pulling the correct node image version: 我得到以下输出,这表明我们正在提取正确的节点映像版本:
Running with gitlab-runner 11.3.1 (0aa5179e)
on gitlab-docker-runner fdcd6979
Using Docker executor with image node:10.15.3 ...
Pulling docker image node:10.15.3 ...
Using docker image sha256:64c810caf95adbe21b5f41be687aa77aaebc197aa92f2b2283da5d57269d2b92 for node:10.15.3 ...
Running on runner-fdcd6979-project-862-concurrent-0 via af166b7f5bef...
Fetching changes...
HEAD is now at b46bb77 output container id
From https://gitlab/siloko/node-test
b46bb77..adab1e3 master -> origin/master
Checking out adab1e31 as master...
Skipping Git submodules setup
$ node -v
v10.15.3
$ if [ -f /.dockerenv ]; then echo "docker-executor"; fi
docker-executor
Job succeeded
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.