docs: function (next, started, err, actuallyRan) {
      /* jshint maxcomplexity: 11 */
      var code = 0;
      var now = new Date();
  
      if (err) {
        if (err.type === 'exitCode') code = err.code;
        if ('number' === typeof err) code = err;
  
        this.status('phase.errored', {
          time: now,
          exitCode: code
        });
  
        if (code === 0) {
          this.error(err);
          return this.done(err, next);
        }
      }
      // Complain if no plugins actually did anything during testing?
      // XXX: should this be a fail hard?
      if (['deploy', 'test'].indexOf(this.phase) !== -1 && utils.sum(actuallyRan) === 0) {
        this.out(`Phase ${this.phase} didn't actually run anything. Check your plugin configuration`, 'warn');
      }
  
      if (this.phase === 'test') {
        this.status('tested', {time: now, exitCode: code});
      }
  
      if (this.phase === 'deploy') {
        this.status('deployed', {time: now, exitCode: code});
      }
  
      var nextPhase = PHASES[PHASES.indexOf(this.phase) + 1];
  
      if (code !== 0) {
        nextPhase = 'cleanup';
      } else if (nextPhase === 'deploy' && this.job.type !== 'TEST_AND_DEPLOY') {
        nextPhase = 'cleanup';
      }
  
      this.status('phase.done', {
        phase: this.phase,
        time: now,
        exitCode: code,
        next: nextPhase,
        elapsed: now.getTime() - started.getTime()
      });
  
      if (this.phase === 'cleanup') {
        return this.done(null, next);
      }
  
      this.phase = nextPhase;
      this.runPhase(next);
    }