Skip to content

Commit

Permalink
Prevent job failure from saying there wasn't an error
Browse files Browse the repository at this point in the history
On processJob error there was no return making it continue on to the success state.
  • Loading branch information
Ilya Radchenko authored Jul 27, 2016
1 parent 18ea9de commit b5a2623
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@

var fs = require('fs-extra');
var path = require('path');

var _ = require('lodash');
var async = require('async');
var debug = require('debug')('strider-simple-runner');
var EventEmitter2 = require('eventemitter2').EventEmitter2;
var Loader = require('strider-extension-loader');

var core = require('strider-runner-core');

var cachier = require('./cachier');
var keeper = require('dirkeeper');
var cachier = require('./cachier');
var JobData = require('./jobdata');
var JobQueue = require('./jobqueue');
var branchFromJob = require('./utils').branchFromJob;
Expand Down Expand Up @@ -332,7 +329,7 @@ Runner.prototype = {
function jobDirsReady(err, dirs) {
if (err) {
var jobdata = self.jobdata.pop(job._id);
if (!jobdata) return next(null);
if (!jobdata) return next();
jobdata.errored = true;
jobdata.error = {
message: err.message,
Expand All @@ -342,17 +339,19 @@ Runner.prototype = {
delete jobdata.data;
jobdata.finished = new Date();
self.emitter.emit('job.done', jobdata);
next(null);
return;

return next();
}

self.jobdata.get(job._id).started = now;
self.emitter.emit('browser.update', job.project.name, 'job.status.started', [job._id, now]);
debug(`[runner:${self.id}] Job started. Project: ${job.project.name} Job ID: ${job._id}`);
debug('Initializing plugins...');
self.plugins(job.project.creator, config, job, dirs, function (err, workers) {
if (err) {
var jobdata = self.jobdata.pop(job._id);
if (!jobdata) return next(null);
if (!jobdata) return next(err);

jobdata.errored = true;
jobdata.error = {
message: err.message,
Expand All @@ -363,14 +362,17 @@ Runner.prototype = {
jobdata.finished = new Date();
self.emitter.emit('job.done', jobdata);
debug(`[runner:${self.id}] Job done with error. Project: ${job.project.name} Job ID: ${job._id}`);
next(null);
return;

return next();
}

var env = {};

if (config.envKeys) {
env.STRIDER_SSH_PUB = config.pubkey;
env.STRIDER_SSH_PRIV = config.privkey;
}

self.config.processJob(job, workers.provider, workers.jobplugins, {
cachier: cache,
baseDir: dirs.base,
Expand All @@ -381,7 +383,7 @@ Runner.prototype = {
env: env
}, function (err) {
var jobdata = self.jobdata.pop(job._id);
if (!jobdata) return next(null);
if (!jobdata) return next(err);

if (err) {
jobdata.errored = true;
Expand All @@ -391,13 +393,14 @@ Runner.prototype = {
};
self.emitter.emit('browser.update', job.project.name, 'job.status.errored', [job._id, jobdata.error]);
debug(`[runner:${self.id}] Job done with error. Project: ${job.project.name} Job ID: ${job._id}`);
return;
}

delete jobdata.data;
jobdata.finished = new Date();
self.emitter.emit('job.done', jobdata);
debug(`[runner:${self.id}] Job done without error. Project: ${job.project.name} Job ID: ${job._id}`);
next(null);
next();
});
});
}
Expand Down

0 comments on commit b5a2623

Please sign in to comment.