如何锁定和解锁jenkins奴隶?像这样的伪代码。
for (slave in hudson.model.Hudson.instance.slaves) {
if (slave.getNodeName() == "slave_need_to_be_lock") {
Computer c = slave.getComputer();
c.lock();
c.unlock();
}
}
答案 0 :(得分:1)
我用下面的代码解决了这个问题。
for (slave in hudson.model.Hudson.instance.slaves) {
if (slave.getNodeName() == "slave_need_to_be_lock") {
Computer c = slave.getComputer();
c.disconnect(); //Just like lock;
c.connect(false); //Just like unlock;
}
}