GitLab runner只执行一个命令

3

我在.gitlab-ci.yml中有以下配置:

stages:
- build

build:
  stage: build
  script:
    - npm install -g gulp
    - npm install
    - gulp

但是该运行程序仅执行第一个命令 (npm install -g gulp),运行第一个命令并报告成功,而不执行其他命令。

构建日志:

Running with gitlab-ci-multi-runner 1.6.1 (c52ad4f)
Using Shell executor...
Running on WINBUILDER...

Fetching changes...

HEAD is now at 2df18c5 Update .gitlab-ci.yml
From https://.../client
   2df18c5..b4efae8  master     -> origin/master
Checking out b4efae85 as master...

$ npm install -g gulp

C:\Users\Administrator\AppData\Roaming\npm\gulp -> C:\Users\Administrator\AppData\Roaming\npm\node_modules\gulp\bin\gulp.js
C:\Users\Administrator\AppData\Roaming\npm
`-- gulp@3.9.1 

Build succeeded

我看到一些配置示例在一个阶段中使用多个命令。我不明白为什么其他命令没有运行。

1个回答

13

实际上这是一个NPM的bug,如下所述:

https://github.com/npm/npm/issues/2938

NPM在退出时关闭了shell,随后的命令没有被执行。

问题中描述了一种解决方法。只需在调用NPM之前添加一个call命令即可。

stages:
- build

build:
  stage: build
  script:
    - call npm install -g gulp
    - call npm install
    - gulp

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接