简体   繁体   English

GitLab CI:在NodeJS上配置yaml文件

[英]GitLab CI: configure yaml file on NodeJS

I have problem with test scss-lint in my project on nodejs. 我在nodejs上的项目中测试scss-lint有问题。

在此处输入图片说明

When tests reach scss-lint, it gives an error. 当测试达到scss-lint时,会产生错误。

How to make sure that tests do not fall with the successful result of the test itself? 如何确保测试不会落在测试本身的成功结果上?

My gitlab-ci.yml 我的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. 您定义的每个作业(gem_lint,install_dependencies和scss-lint)都使用其自己的上下文运行。 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. 因此,您的问题在于,在最后一步中,它找不到您安装的scss-lint gem,因为它切换了上下文。

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 : 当然,为此,您需要具有同时安装了npm和gem的docker映像,也许您可​​以在docker hub上找到一个),或者您可以选择一个(例如:ruby:latest),然后将另一个将安装npm:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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