When I try to install NVM using gitlab-ci I get the following error message:
.gitlab-ci.yml file
stages:
- test
Testing:
tags:
- docker
stage: test
image: ubuntu:18.04
before_script:
- apt-get update
- apt-get install curl -y
# Install Node Version Manager (NVM) so we can change the node version
- curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.36.0/install.sh | bash
- nvm --version
Error message:
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.36.0/install.sh | bash
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 13527 100 13527 0 0 99463 0 --:--:-- --:--:-- --:--:-- 99463
=> Downloading nvm as script to '/root/.nvm'
=> Appending nvm source string to /root/.bashrc
=> Appending bash_completion source string to /root/.bashrc
=> Close and reopen your terminal to start using nvm or run the following to use it now:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
$ nvm --version
/bin/bash: line 116: nvm: command not found
ERROR: Job failed: exit code 1
When I try to reload the terminal in gitlab-ci using exec bash the gitlab task ends prematurely, and does not run the rest of the script.
How do I use install and use nvm with gitlab-ci ?