Search code examples
codeshipgulp-jasmine

Continuous Integration: Codeship + Gulp (Jasmine)


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.


Solution

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