Gitlab CI shell on Windows only runs before_script

999 views
Skip to first unread message

dsbert

unread,
Aug 19, 2016, 9:45:39 AM8/19/16
to GitLab

My CI runner will only run a single line. I'm trying to run npm install prior to eslint. However, if I add npm install to the before_script section, then only npm install runs and the build reports success without ever actually running eslint. Are multiple commands not supported on a windows shell runner?

I also tried moving npm install into the lint job, with the same result. The only way I was able to get this to work is by putting both commands into one line as npm install&&eslint **/*.js

I have installed the gitlab multi-runner on a windows host. Here is my .gitlab-ci.yml


before_script:
  - npm install

stages:
  - test

cache:
  key: "$CI_BUILD_REF_NAME"
  paths:
    - node_modules/

lint:
  stage: test
  tags:
    - javascript
  script:
    - eslint **/*.js

Drew Blessing

unread,
Aug 23, 2016, 5:54:48 PM8/23/16
to GitLab
Can you show the syntax you used to add both script lines to the actual job? Also, please share the build output if you can (sanitize stuff, if necessary). What runner version are you using?

dsbert

unread,
Aug 29, 2016, 9:21:47 AM8/29/16
to GitLab
I'm not quite sure what you are asking for in regards to script lines to add the job. I downloaded the gitllab runner (vers. 1.4.2) to my local machine. I ran through the basic set up, using the token from my gitlab repository and registered it as a service. I then added the .gitlab-ci.yml file to my repository with the following contents.

before_script:
 
- npm install
 
stages
:
 
-
test
 
- deploy

cache
:

  key
: "$CI_BUILD_REF_NAME"
  paths
:
   
- node_modules/


mocha
:

  stage
: test
  tags
:
   
- javascript
  script
:

   
- set NODE_ENV=test
   
- mocha ./tests/**/*.js

lint
:

  stage
: test
  tags
:
   
- javascript
  script
:

   
- eslint */**

apidoc:
  stage: deploy
  tags:
    - javascript
  script:
    - apidoc -e node_modules -o c:\docs\api\

Here is the total output from the lint job. The only thing shown is the npm install step. Other jobs I've tried appear the same.

Running with gitlab-ci-multi-runner 1.4.2 (bcc1794)
Using Shell executor...
Running on US2976NB...


Fetching changes...


Removing node_modules/
HEAD
is now at 800016a Fix eslint glob
From http://redacted
   
5030d8a..c66df4a  feature/sequelize -> origin/feature/sequelize
Checking out 800016ac as feature/ci...


Checking cache for feature/ci...


$ npm install


npm WARN optional
Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup
Not compatible with your operating system or architecture: fsevents@1.0.14
Creating cache feature/ci...


node_modules
/: found 13865 matching files          
Build succeeded


And finally,

this is what the gitlab runner config.toml contains

concurrent = 1
check_interval
= 0


[[runners]]
  name
= "redacted"
  url
= "redacted"
  token
= "redacted"
  executor
= "shell"
  tags
= ["javascript"]
 
[runners.ssh]
 
[runners.docker]
    tls_verify
= false
    image
= ""
    privileged
= false
    disable_cache
= false
 
[runners.parallels]
    base_name
= ""
    disable_snapshots
= false
 
[runners.virtualbox]
    base_name
= ""
    disable_snapshots
= false
 
[runners.cache]
   
Insecure = false

dsbert

unread,
Sep 19, 2016, 5:21:56 PM9/19/16
to GitLab
I found a solution to this issue. It appears using the platform default shell (cmd.exe) was causing the runner to exit with a successful build on the first return code from a command, ignoring the rest of the commands. Changing the shell to "powershell" in the runner config.toml resulted in all commands running and the last return code being used.

Drew Blessing

unread,
Sep 21, 2016, 1:09:02 AM9/21/16
to GitLab
I'm glad to hear this has been resolved.
Reply all
Reply to author
Forward
0 new messages