Continuous Integration: Codeship + Gulp (Jasmine)

781 views Asked by At

My Continuous Integration works pretty great using Codeship except one thing: stop deploying and alert us when unit tests are failing.

Here is our current commands:

  1. npm install
  2. npm install bower
  3. bower install
  4. gulp test
  5. gulp build

The problem is whether gulp test end with success or fail, the gulp build builds.

I succeed to console.log() my gulp test exit status but I have no idea about how to make Codeship listen to this exit status.

3

There are 3 answers

0
MaximeBernard On BEST ANSWER

Using @mlocker answer and this discussion on Github, I've found a workaround that works fine for me:

gulp.task('test', function (done) {
  karma.start({}, function(exitStatus){
    done(exitStatus ? "There are failing unit tests" : undefined);
  });
});

The trick here is that if the exitStatus is different from 0, you'll get a formatError on "There are failing unit tests" which will exit gulp test with 1 making Codeship to stop and consider the build as failed.

0
mlocher On

The build on Codeship will fail as soon as any command exits with an exit code other than zero.

Please make sure this is the case with running gulp test.

(You can also reach out to us via [email protected] if any other questions come up!)

1
mcniac On

maybe you can try chaining the test and build tasks?

gulp test && gulp build