I'm very new to GitLab and am trying to set up the CI/CD system for my project.
My .gitlab-ci.yml
file is as follows:
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.
How do I tell GitLab CI to use Node 10.15.3?
It might be a security vulnerability The code in your most recent commit could be vulnerable, or a dependency could be at risk, either of which would trigger a failed security test and thus a failed pipeline.
Get logs to diagnose problems You can view logs by navigating to the pipeline run summary and selecting the job and task. If a certain task is failing, check the logs for that task.
If you want to use Gitlab's CI(ci.gitlab.com), then your coordinator url is https://ci.gitlab.com/
If you have a public, open source project on GitHub you can now take advantage of free CI/CD on GitLab.com. As part of our commitment to open source, we offer all public projects our highest tier features (GitLab SaaS Ultimate) for free.
You are not tagging your job so perhaps it is running on a shell-executor
and not a docker-executor
. Check for .dockerenv
in your job spec to ensure you're running in a container;
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With