Daniel
Daniel

Reputation: 45

Gitlab Runner Job failed

Our Gitlab Runner job always aborts when trying to make an npm install. It means that npm is not found or installed. It will be installed above and worked fine until a few days ago. Anyone have an idea? I add our gitlab-ci.yml to the attachment, I'm a bit helpless...

image: "ruby:2.5.5"

variables:
  RAILS_ENV: "test"
  GIT_DEPTH: "1"
  APT_PACKAGES: "nodejs postgresql postgresql-contrib libpq-dev sudo fontconfig bzip2 curl libxss1 libappindicator1 libindicator7 libpango1.0-0 fonts-liberation xdg-utils cmake"

cache:
  key: "ruby-255"
  paths:
  - vendor/ruby
  - vendor/apt
  - node_modules
  - frontend/node_modules
  - frontend/bower_components

before_script:
  # Setup deploy key
  - mkdir -pv ~/.ssh
  - echo "StrictHostKeyChecking no" >> ~/.ssh/config
  - eval $(ssh-agent -s)
  - ssh-add <(echo "$DEPLOY_KEY")

  # Install dependencies
  - mkdir -pv vendor/apt
  - curl -sL https://deb.nodesource.com/setup_8.x | bash -
  - apt-get -o dir::cache::archives="vendor/apt" update -yqqq
  - apt-get -o dir::cache::archives="vendor/apt" install -y -qq --force-yes --no-install-recommends $APT_PACKAGES

  # Setup phantomjs
  - curl --silent --show-error --location --fail --retry 3 https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2 | tar xjfO - phantomjs-2.1.1-linux-x86_64/bin/phantomjs > /usr/bin/phantomjs && chmod +x /usr/bin/phantomjs

  # Install node packages, gems and tools, configure and run bundler
  - gem install bundler
  - npm -g install [email protected] ember-cli [email protected] bower
  - RAILS_ENV=test bundle install --path vendor --without development --jobs $(nproc) "${FLAGS[@]}"
  - RAILS_ENV=test bundle lock --add-platform java

  # Setup postgresql database
  - /etc/init.d/postgresql start
  - sudo -u postgres psql -U postgres -d postgres -c "alter user postgres with password 'postgres';"

  # Setup the build
  - cp .env.ci .env
  - RAILS_ENV=test bin/build

stages:
  - check

setup:
  stage: check
  script:
    - node -v
    - npm -v
    - ruby -v
    - bin/check

After the line 'npm -g install [email protected] ember-cli [email protected] bower' comes the following error: /bin/bash: line 103: npm: command not found ERROR: Job failed: exit code 1.

My Gitlab Version: gitlab version

Upvotes: 2

Views: 2169

Answers (1)

Nicolas Pepinster
Nicolas Pepinster

Reputation: 6191

ruby:2.5.5 image you use doesn't contain npm executable :

docker run -it --rm ruby:2.5.5 npm -version
/usr/bin/docker-current: Error response from daemon: oci runtime error: container_linux.go:247: starting container process caused "exec: \"npm\": executable file not found in $PATH".

Try to use ruby-node image instead :

docker run -it --rm starefossen/ruby-node /bin/bash -c "ruby -v; node -v; npm -v"
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]
v10.8.0
6.2.0

Upvotes: 3

Related Questions