mirror of
https://gitlab.silvrtree.co.uk/martind2000/nci.git
synced 2025-02-14 00:49:16 +00:00
add blocks support
This commit is contained in:
parent
85844bcb40
commit
63d244818d
@ -21,6 +21,13 @@ trigger:
|
||||
- status: done
|
||||
project: project2
|
||||
|
||||
blockedBy:
|
||||
# - project2
|
||||
- !!js/regexp /project2|nci/
|
||||
|
||||
blocks:
|
||||
- project2
|
||||
|
||||
steps:
|
||||
- cmd: >
|
||||
echo "long multiline string" &&
|
||||
|
44
lib/node.js
44
lib/node.js
@ -12,6 +12,19 @@ function Node(params) {
|
||||
|
||||
exports.Node = Node;
|
||||
|
||||
Node.prototype._getBlockerExecutor = function(getBlockers, getTarget) {
|
||||
return _(this.executors).find(function(executor) {
|
||||
var target = getTarget(executor);
|
||||
return _(getBlockers(executor)).find(function(blocker) {
|
||||
if (_(blocker).isRegExp()) {
|
||||
return blocker.test(target);
|
||||
} else {
|
||||
return blocker === target;
|
||||
}
|
||||
});
|
||||
})
|
||||
};
|
||||
|
||||
Node.prototype.getExecutorWaitReason = function(project) {
|
||||
var waitReason;
|
||||
|
||||
@ -19,6 +32,37 @@ Node.prototype.getExecutorWaitReason = function(project) {
|
||||
waitReason = 'All executors are busy';
|
||||
} else if (project.name in this.executors) {
|
||||
waitReason = 'Project already running on node';
|
||||
} else {
|
||||
var blockerExecutor;
|
||||
|
||||
if (project.blockedBy) {
|
||||
blockerExecutor = this._getBlockerExecutor(
|
||||
function(executor) {
|
||||
return project.blockedBy;
|
||||
},
|
||||
function(executor) {
|
||||
return executor.project.name;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if (!blockerExecutor) {
|
||||
blockerExecutor = this._getBlockerExecutor(
|
||||
function(executor) {
|
||||
return executor.project.blocks;
|
||||
},
|
||||
function(executor) {
|
||||
return project.name;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if (blockerExecutor) {
|
||||
waitReason = (
|
||||
'Blocked by currently running "' +
|
||||
blockerExecutor.project.name + '"'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return waitReason;
|
||||
|
Loading…
Reference in New Issue
Block a user