我想有一个看起来像这样的Jenkins构建流程。
我几周前才开始和Jenkins一起工作,他们现在设置它的方式就是每个工作都由奴隶接收,他们必须首先运行设置工作。这确实减慢了构建时间,因为我有大约30个作业,并且设置需要大约2分钟。
我使用Jenkins作为自动化测试平台,并且作业池中的所有作业可以彼此独立运行。我目前有5个奴隶,约有30个工作岗位。
答案 0 :(得分:0)
以下应该可以解决问题:
else
只需将“作业池作业”添加到def jobPool = new ArrayDeque()
jobPool.add({
echo "Doing stuff on ${env.NODE_NAME}"
});
jobPool.add({
echo "Doing other stuff on ${env.NODE_NAME}, a little slower"
sleep 4
});
jobPool.add({
echo "Doing more stuff on ${env.NODE_NAME}, even slower"
sleep 10
});
jobPool.add({
echo "Doing stuff quick on ${env.NODE_NAME}"
});
jobPool.add({
echo "Doing stuff quicker on ${env.NODE_NAME}"
});
def par = [:]
for (x in ["master", "urban"]) {
def nodeName = x; // needed due to variable scoping
par[nodeName] = {
node (nodeName) {
try {
echo "Doing setup on ${env.NODE_NAME}!"
// Do you're setup
echo "Done with setup"
} catch (Exception e) {
echo "Will not use this node as it failed setup!"
return;
}
while (true) {
// echo "${jobPool.size()}"
def subTask = jobPool.poll()
//echo "${jobPool.size()} ${subTask}"
if (subTask == null) {
break;
}
// Might wan't try catch around the next line if you wan't to continue if a job fails
subTask()
}
}
}
}
parallel par
if (!jobPool.isEmpty()) {
error "Not all tasks was done!"
}
变量并修改设置部分。
答案 1 :(得分:0)
看起来你想在同一份工作中分别进行各个阶段。这在jenkins 2的管道中变得更加容易。这里有一些图片: https://wiki.jenkins-ci.org/display/JENKINS/Pipeline+Stage+View+Plugin
node {
stage 'Checkout'
svn 'https://svn.mycorp/trunk/'
stage 'Build'
sh 'make all'
stage 'Test'
sh 'make test'
}