1

I'm using GitLab's "CI Multi-Runner", which I have installed on Windows 2012 R2 instance. Builds start correctly and begin to run, but the build is marked as complete before it even runs my entire script.

.gitlab-ci.yml

build_web:
  script:
    - cd Web
    - npm install
    - jspm install
    - gulp build

Upon pushing, the pipeline runs through npm install and then outputs "Build succeeded" and ends the build successfully (having skipped the following two commands).

Josh M.
  • 679
  • 1
  • 10
  • 21

2 Answers2

2

I've been having these early exit issues on GitLab CI with Windows with NodeJs / NPM commands. I solved it using PowerShell to wrap the commands in place of directly calling NPM

replacing:

- npm install

with:

- powershell -Command "Start-Process npm -ArgumentList install -Wait"

In my case I needed to run grunt as well which caused the same issue so similarly wrapped like

powershell -Command "Start-Process grunt -ArgumentList autobuild -Wait"

Hope that works for you
Toby

tobyd
  • 471
  • 1
  • 3
  • 12
  • You might have a better experiance switching the runner to use PowerShell rather than cmd. in the config.toml file in the directory the runner resides in add – tobyd Oct 27 '16 at 12:07
  • `shell = "powershell"` below the `executor = "shell"` line – tobyd Oct 27 '16 at 12:09
  • @tobyd, do you have any idea why these early exists are happening? I had the same issue and it helped, thanks! – Olexander Ivanitskyi Nov 03 '16 at 11:35
  • 1
    @Olexander, No problem - Glad it helped. I'm not sure why this occurs, npm seems to be tripping up GitLab runner in a way it doesn't upset PowerShell. I've found PowerShell a more flexible shell for my process anyway as it can manage UNC paths. – tobyd Nov 03 '16 at 13:51
  • 1
    @Olexander, came across this - seems like its just a gitlab processor thing https://forum.gitlab.com/t/gitlab-ci-not-running-script-strings/4845 looks like you just need to run npm as `npm install --silent` to prevent it exiting early. – tobyd Dec 02 '16 at 11:07
2

Change npm install to call npm install. This is how the Windows shell works, if you don't use call it will execute in the same context and then exit after running.

Gaui
  • 169
  • 7