add blocks support
This commit is contained in:
parent
85844bcb40
commit
63d244818d
@ -21,6 +21,13 @@ trigger:
|
|||||||
- status: done
|
- status: done
|
||||||
project: project2
|
project: project2
|
||||||
|
|
||||||
|
blockedBy:
|
||||||
|
# - project2
|
||||||
|
- !!js/regexp /project2|nci/
|
||||||
|
|
||||||
|
blocks:
|
||||||
|
- project2
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- cmd: >
|
- cmd: >
|
||||||
echo "long multiline string" &&
|
echo "long multiline string" &&
|
||||||
|
44
lib/node.js
44
lib/node.js
@ -12,6 +12,19 @@ function Node(params) {
|
|||||||
|
|
||||||
exports.Node = Node;
|
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) {
|
Node.prototype.getExecutorWaitReason = function(project) {
|
||||||
var waitReason;
|
var waitReason;
|
||||||
|
|
||||||
@ -19,6 +32,37 @@ Node.prototype.getExecutorWaitReason = function(project) {
|
|||||||
waitReason = 'All executors are busy';
|
waitReason = 'All executors are busy';
|
||||||
} else if (project.name in this.executors) {
|
} else if (project.name in this.executors) {
|
||||||
waitReason = 'Project already running on node';
|
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;
|
return waitReason;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user