diff --git a/data/projects/project1/config.yaml b/data/projects/project1/config.yaml index 5d37f68..d71ab52 100644 --- a/data/projects/project1/config.yaml +++ b/data/projects/project1/config.yaml @@ -4,8 +4,8 @@ scm: repository: ./test/repos/mercurial rev: default -# catchRev: -# comment: !!js/regexp // +catchRev: + comment: !!js/regexp // notify: on: @@ -45,7 +45,7 @@ steps: - cmd: cat 1.txt 2.txt - shell: /bin/bash cmd: > - for i in {1..30}; do + for i in {1..10}; do echo "tick $i"; sleep 0.3; done; diff --git a/lib/distributor.js b/lib/distributor.js index af29962..2f06096 100644 --- a/lib/distributor.js +++ b/lib/distributor.js @@ -5,7 +5,8 @@ var Steppy = require('twostep').Steppy, Node = require('./node').Node, EventEmitter = require('events').EventEmitter, inherits = require('util').inherits, - notifier = require('./notifier'); + notifier = require('./notifier'), + utils = require('./utils'); function Distributor(params) { @@ -97,6 +98,18 @@ Distributor.prototype._runNext = function(callback) { executor.once('scmData', function(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 diff --git a/lib/executor/base.js b/lib/executor/base.js index 252c81e..c9d22f2 100644 --- a/lib/executor/base.js +++ b/lib/executor/base.js @@ -74,7 +74,7 @@ Executor.prototype._getTarget = function(rev, changes) { if (index !== -1) { result.rev = changes[index].id; - result.changes = changes.slice(0, index); + result.changes = changes.slice(0, index + 1); result.changes.reverse(); } diff --git a/lib/executor/local.js b/lib/executor/local.js index 7010c68..f5fa02e 100644 --- a/lib/executor/local.js +++ b/lib/executor/local.js @@ -65,16 +65,11 @@ Executor.prototype._getSources = function(params, callback) { this.pass(changes); scm.getRev(params.rev, this.slot()); }, - function(err, rev, 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); - } - + function(err, currentRev, changes, latestRev) { this.pass({ - rev: rev, + rev: currentRev, changes: changes, - isLatest: changes.length && changes[0].id === latestRev.id + isLatest: currentRev.id === latestRev.id }); }, callback