简体   繁体   中英

GitLab CI: configure yaml file on NodeJS

I have problem with test scss-lint in my project on nodejs.

在此处输入图片说明

When tests reach scss-lint, it gives an error.

How to make sure that tests do not fall with the successful result of the test itself?

My gitlab-ci.yml

image: node:wheezy

cache:
  paths:
    - node_modules/

stages:
  - build
  - test

gem_lint:
  image: ruby:latest
  stage: build
  script:
    - gem install scss_lint
  artifacts:
    paths:
     - node_modules/
  only:
    - dev
  except:
    - master

install_dependencies:
  stage: build
  script:
    - npm install
  artifacts:
    paths:
      - node_modules/
  only:
    - dev
  except:
    - master

scss-lint:
  stage: test
  script:
    - npm run lint:scss-lint
  artifacts:
    paths:
      - node_modules/
  only:
    - dev
  except:
    - master

You are doing it wrong.

Each job you define (gem_lint, install_dependencies, and scss-lint) is run with its own context. So your problem here is that during the last step, it doesn't find the scss-lint gem you installed because it switched its context.

You should execute all the scripts at the same time in the same context :

  script:
    - gem install scss_lint
    - npm install
    - npm run lint:scss-lint

Of course for this you need to have a docker image that has both npm and gem installed maybe you can find one on docker hub), or you can choose one (for example : ruby:latest) and add as the first script another one that would install npm :

    - curl -sL https://deb.nodesource.com/setup_6.x | bash - 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM