如何使用groovy锁定和解锁jenkins slave?

nfeuvbwi  于 12个月前  发布在  Jenkins
关注(0)|答案(1)|浏览(184)

如何锁定和解锁Jenkins slave?像这样的伪代码。

for (slave in hudson.model.Hudson.instance.slaves) {
  if (slave.getNodeName() == "slave_need_to_be_lock") {
    Computer c = slave.getComputer();
    c.lock();
    c.unlock();
  }
}

字符串

vlf7wbxs

vlf7wbxs1#

我用下面的代码来实现它。

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;
  }
}

字符串

相关问题