4

I am Pretty new to Team City and have been set with a task of creating a CI build.

The thing I trying to build is an angular2 app with protractor e2e tests.

All the other build steps in Team City run ok but I am having trouble trying to run the step that does the e2e test.

if I was to do this locally I would open a cmd window and type...

npm run start

I would then open another command window and type...

npm run e2e 

How do I run parallel steps in Team City?

naimdjon
  • 3,162
  • 1
  • 20
  • 41
dazziep
  • 245
  • 1
  • 4
  • 16

2 Answers2

6

Build steps cannot be run parallel in TeamCity. What you need to do, is create a script that runs 'npm run start' in background, and then runs 'npm run e2e'. You can use command line runner to run the script

Oleg Rybak
  • 1,651
  • 1
  • 14
  • 27
  • yeah I tried creating add an npm script that would do it but it just hangs after running up the server.. "serve-e2e": "npm run server:dev & npm run e2e", – dazziep Feb 03 '16 at 09:45
  • 1
    The command "npm run server:dev" does not run server in background. It starts the server and waits for the command to return, that never happens. You need to use tools like https://www.npmjs.com/package/forever to run the server in background. – Oleg Rybak Feb 03 '16 at 09:56
  • do you know how/if you can use it directly to start npm commands `npm run server:dev` as it looks like it fires off js script `forever start app.js` , sorry for seeming dumb here. – dazziep Feb 03 '16 at 10:24
  • I don't know the exact solution, but this answer to SO question http://stackoverflow.com/a/33424241/256776 and this github discussion https://github.com/foreverjs/forever/issues/540 might have some ideas – Oleg Rybak Feb 03 '16 at 10:38
3

I still couldn't get the forever thing working properly for me so I created my own node script that fires up live-server and then executes npm run e2e and that seems to have done the trick thanks for your help though Oleg.

This is how I did it in the end...

const exec = require('child_process').exec;
var psTree = require('ps-tree');

const server = exec('live-server ./dist --port=3000 --no-browser');
const tests = exec('npm run e2e');

tests.stdout.on('data', function(data) {
  console.log(data);
});
tests.stderr.on('data', function(data) {
  console.log(data);
});
tests.on('close', function(code) {
  console.log('closing code: ' + code);
  exec('taskkill /PID ' + server.pid + ' /T /F');
});
dazziep
  • 245
  • 1
  • 4
  • 16