run the same project again if we don't reach the latest rev

This commit is contained in:
oleg 2015-06-25 00:54:33 +03:00
parent 5428347bfe
commit 827c3d4888
4 changed files with 21 additions and 13 deletions

View File

@ -4,8 +4,8 @@ scm:
repository: ./test/repos/mercurial repository: ./test/repos/mercurial
rev: default rev: default
# catchRev: catchRev:
# comment: !!js/regexp // comment: !!js/regexp //
notify: notify:
on: on:
@ -45,7 +45,7 @@ steps:
- cmd: cat 1.txt 2.txt - cmd: cat 1.txt 2.txt
- shell: /bin/bash - shell: /bin/bash
cmd: > cmd: >
for i in {1..30}; do for i in {1..10}; do
echo "tick $i"; echo "tick $i";
sleep 0.3; sleep 0.3;
done; done;

View File

@ -5,7 +5,8 @@ var Steppy = require('twostep').Steppy,
Node = require('./node').Node, Node = require('./node').Node,
EventEmitter = require('events').EventEmitter, EventEmitter = require('events').EventEmitter,
inherits = require('util').inherits, inherits = require('util').inherits,
notifier = require('./notifier'); notifier = require('./notifier'),
utils = require('./utils');
function Distributor(params) { function Distributor(params) {
@ -97,6 +98,18 @@ Distributor.prototype._runNext = function(callback) {
executor.once('scmData', function(scmData) { executor.once('scmData', function(scmData) {
self._updateBuild(build, {scm: scmData}); self._updateBuild(build, {scm: scmData});
// run the same project again if we don't reach the latest rev
if (!scmData.isLatest) {
self.run({
projectName: build.project.name,
initiator: {
type: 'build',
id: build.id,
number: build.number,
project: {name: build.project.name}
},
}, utils.logErrorCallback);
}
}); });
// update wait reasons for all queue items after run // update wait reasons for all queue items after run

View File

@ -74,7 +74,7 @@ Executor.prototype._getTarget = function(rev, changes) {
if (index !== -1) { if (index !== -1) {
result.rev = changes[index].id; result.rev = changes[index].id;
result.changes = changes.slice(0, index); result.changes = changes.slice(0, index + 1);
result.changes.reverse(); result.changes.reverse();
} }

View File

@ -65,16 +65,11 @@ Executor.prototype._getSources = function(params, callback) {
this.pass(changes); this.pass(changes);
scm.getRev(params.rev, this.slot()); scm.getRev(params.rev, this.slot());
}, },
function(err, rev, changes, latestRev) { function(err, currentRev, changes, latestRev) {
// add current rev to the lates changes (if it's not yet there)
if (changes.length && changes[0].id !== rev.id) {
changes.unshift(rev);
}
this.pass({ this.pass({
rev: rev, rev: currentRev,
changes: changes, changes: changes,
isLatest: changes.length && changes[0].id === latestRev.id isLatest: currentRev.id === latestRev.id
}); });
}, },
callback callback