Job can run successful without executing all script commands on Windows
Summary
The Windows version does not always execute all commands of the job's script. The script execution can somehow get interrupted by a command. For me Node's NPM command produces this behavior consistently. It interrupts/stops the script execution without any errors and then returns success.
Steps to reproduce
Create a simple Node.js project with a failing example test (I used mocha).
In package.json
add test script so it can be called via NPM.
Add a gitlab-ci config file: .gitlab-ci.yml
stages:
- test
all_tests:
stage: test
script:
- npm install
- npm test
Here's the example project:
https://gitlab.com/alexbeer/gitlab-runner-fail-test.git
Set up a gitlab runner for Node on Windows:
- Install latest Node.js (v8.x) w/ NPM
- Register gitlab-runner
- Use executor: 'shell'
Push project to gitlab and run test job with our Windows based runner.
Actual behavior
The test runs successful.
Expected behavior
The test should fail.
Relevant logs and/or screenshots
Running with gitlab-ci-multi-runner 9.5.0 (413da38)
on abe-test-winsrv2012-nodejs8 (5ec4c44a)
Using Shell executor...
Running on my-virtual-machine...
Cloning repository...
Cloning into 'C:/GitLab-Runner/builds/5ec4c44a/0/alexbeer/gitlab-runner-fail-test'...
Checking out 1f46c467 as master...
Skipping Git submodules setup
$ npm install
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN gitlab-runner-fail-test@1.0.0 No description
npm WARN gitlab-runner-fail-test@1.0.0 No repository field.
added 41 packages in 15.147s
Job succeeded
For some reason, after this first line of the script (npm install
) it seems to be happy with the result and then ignore the rest.
Here is the log of the same job running on Linux:
Running with gitlab-ci-multi-runner 9.5.0 (413da38)
on abe-test-debian-nodejs8 (639122a9)
Using Shell executor...
Running on my-other-virtual-machine...
Cloning repository...
Cloning into '/home/gitlab-runner/builds/639122a9/0/alexbeer/gitlab-runner-fail-test'...
Checking out 1f46c467 as master...
Skipping Git submodules setup
$ npm install
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN gitlab-runner-fail-test@1.0.0 No description
npm WARN gitlab-runner-fail-test@1.0.0 No repository field.
added 41 packages in 7.119s
$ npm test
> gitlab-runner-fail-test@1.0.0 test /home/gitlab-runner/builds/639122a9/0/alexbeer/gitlab-runner-fail-test
> mocha
Test
1) will fail
0 passing (59ms)
1 failing
1) Test will fail:
AssertionError: We're dooomed!!!
at Context.<anonymous> (test/fail.js:5:9)
npm ERR! Test failed. See above for more details.
ERROR: Job failed: exit status 1
Instead of 'Job succeeded' this one continues with the next line of the job script npm test
as expected.
Note:
Not every command interrupts the script. To investigate where the bug might be, I used some $echo
commands within the job script to see what's going on and they did not stop the process. But a simple command to show NPM's version npm --version
did stop the process.
Environment description
OS: Microsoft Windows Server 2012
> .\gitlab-runner.exe --version
Version: 9.5.0
Git revision: 413da38
Git branch: 9-5-stable
GO version: go1.8.3
Built: Tue, 22 Aug 2017 13:40:42 +0000
OS/Arch: windows/amd64
> node --version
v8.4.0
> npm --version
5.3.0