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).

2 Answers 2

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

5
  • 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, 2016 at 12:07
  • shell = "powershell" below the executor = "shell" line
    – tobyd
    Oct 27, 2016 at 12:09
  • @tobyd, do you have any idea why these early exists are happening? I had the same issue and it helped, thanks! Nov 3, 2016 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 3, 2016 at 13:51
  • 1
    @Olexander, came across this - seems like its just a gitlab processor thing 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 2, 2016 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.