mirror of
https://gitlab.silvrtree.co.uk/martind2000/nci.git
synced 2025-01-11 09:55:09 +00:00
provide scm info for build
This commit is contained in:
parent
da580dd813
commit
39786933de
@ -9,7 +9,7 @@ work in progress...
|
|||||||
* Dashboard (builds list, projects autocomlete)
|
* Dashboard (builds list, projects autocomlete)
|
||||||
* Build page (build info, console)
|
* Build page (build info, console)
|
||||||
* Url for trigger build run
|
* Url for trigger build run
|
||||||
* YAML project configs
|
* YAML project and server(executors count, etc) configs
|
||||||
* Persistent builds
|
* Persistent builds
|
||||||
* Project relations (blocks, triggers, etc)
|
* Project relations (blocks, triggers, etc)
|
||||||
* Mail and jabber notifications (with commits, current step and error)
|
* Mail and jabber notifications (with commits, current step and error)
|
||||||
|
@ -51,6 +51,7 @@ Distributor.prototype._runNext = function(callback) {
|
|||||||
var queueItem = self.queue[queueItemIndex];
|
var queueItem = self.queue[queueItemIndex];
|
||||||
this.pass(queueItemIndex, queueItem);
|
this.pass(queueItemIndex, queueItem);
|
||||||
|
|
||||||
|
queueItem.build.startDate = Date.now();
|
||||||
queueItem.build.status = 'in-progress';
|
queueItem.build.status = 'in-progress';
|
||||||
self._updateBuild(queueItem.build, this.slot());
|
self._updateBuild(queueItem.build, this.slot());
|
||||||
},
|
},
|
||||||
@ -59,6 +60,7 @@ Distributor.prototype._runNext = function(callback) {
|
|||||||
|
|
||||||
var stepCallback = this.slot();
|
var stepCallback = this.slot();
|
||||||
var executor = node.run(queueItem.project, build.params, function(err) {
|
var executor = node.run(queueItem.project, build.params, function(err) {
|
||||||
|
build.endDate = Date.now();
|
||||||
build.status = err ? 'error' : 'done';
|
build.status = err ? 'error' : 'done';
|
||||||
build.error = err;
|
build.error = err;
|
||||||
self._updateBuild(build, function(err, build) {
|
self._updateBuild(build, function(err, build) {
|
||||||
@ -75,6 +77,11 @@ Distributor.prototype._runNext = function(callback) {
|
|||||||
executor.on('data', function(data) {
|
executor.on('data', function(data) {
|
||||||
self.onBuildData(build, data);
|
self.onBuildData(build, data);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
executor.once('scmData', function(scmData) {
|
||||||
|
build.scm = scmData;
|
||||||
|
self._updateBuild(build);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
callback
|
callback
|
||||||
);
|
);
|
||||||
|
@ -31,7 +31,8 @@ Executor.prototype.run = function(params, callback) {
|
|||||||
self.emit('currentStep', 'get sources');
|
self.emit('currentStep', 'get sources');
|
||||||
self._getSources(project.scm, this.slot());
|
self._getSources(project.scm, this.slot());
|
||||||
},
|
},
|
||||||
function() {
|
function(err, scmData) {
|
||||||
|
self.emit('scmData', scmData);
|
||||||
var funcs = project.steps.map(function(step, index) {
|
var funcs = project.steps.map(function(step, index) {
|
||||||
return function() {
|
return function() {
|
||||||
var stepLabel = step.name || utils.prune(step.cmd, 15);
|
var stepLabel = step.name || utils.prune(step.cmd, 15);
|
||||||
|
@ -18,7 +18,7 @@ exports.Executor = Executor;
|
|||||||
|
|
||||||
Executor.prototype._getSources = function(params, callback) {
|
Executor.prototype._getSources = function(params, callback) {
|
||||||
var self = this,
|
var self = this,
|
||||||
scm, isFirstRun;
|
scm, isFirstRun, oldRev;
|
||||||
Steppy(
|
Steppy(
|
||||||
function() {
|
function() {
|
||||||
var slot = this.slot();
|
var slot = this.slot();
|
||||||
@ -36,6 +36,16 @@ Executor.prototype._getSources = function(params, callback) {
|
|||||||
isFirstRun = true;
|
isFirstRun = true;
|
||||||
}
|
}
|
||||||
scm = createScm(scmParams);
|
scm = createScm(scmParams);
|
||||||
|
|
||||||
|
if (isFirstRun) {
|
||||||
|
this.pass(null);
|
||||||
|
} else {
|
||||||
|
scm.getCurrent(this.slot());
|
||||||
|
}
|
||||||
|
},
|
||||||
|
function(err, id) {
|
||||||
|
oldRev = id;
|
||||||
|
|
||||||
if (isFirstRun) {
|
if (isFirstRun) {
|
||||||
scm.clone(self.cwd, params.rev, this.slot());
|
scm.clone(self.cwd, params.rev, this.slot());
|
||||||
} else {
|
} else {
|
||||||
@ -49,6 +59,13 @@ Executor.prototype._getSources = function(params, callback) {
|
|||||||
this.pass(null);
|
this.pass(null);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
function() {
|
||||||
|
scm.getCurrent(this.slot());
|
||||||
|
scm.getChanges(oldRev && oldRev.id, params.rev, this.slot());
|
||||||
|
},
|
||||||
|
function(err, rev, changes) {
|
||||||
|
this.pass({rev: rev, changes: changes});
|
||||||
|
},
|
||||||
callback
|
callback
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -46,8 +46,18 @@ var expect = require('expect.js'),
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should run', function(done) {
|
it('should run', function() {
|
||||||
executor.run({}, done);
|
executor.run({}, function(err) {
|
||||||
|
expect(err).not.ok();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should emit scm data', function(done) {
|
||||||
|
executor.on('scmData', function(scmData) {
|
||||||
|
expect(scmData).have.keys('rev', 'changes');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user