我如何获得Jenkins节点的在线时间 [英] How can I get online time for a Jenkins Node

查看:215
本文介绍了我如何获得Jenkins节点的在线时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在进行涉及节点更新的特定操作之后,我们希望使Jenkins从节点恢复联机,然后重新启动该节点.

We would like to bring a Jenkins slave node back online after a specific operation involving updates to the node, then rebooting the node.

目的是确保当已知该节点已更新时,我们对其进行监视,并在该节点再次联机时,向调度程序发出信号,告知他们可以开始在该节点上重新分配资源.

The intent is to ensure that when that node is know to have been updated, we monitor it, and when it is online again, signal to our schedulers that they can start allocating resources on that node again.

问题在于,联机还不够,因为要求重新启动可能并不意味着计算机会立即这样做,因此Jenkins节点可能会保持在线一段时间.因此,我们的想法是查看自从该节点在Jenkins上线以来的时间是否突然减少,并以此作为触发条件.

The problem is that online is not enough, as asking to reboot may not mean the computer does so immediately, so the Jenkins node may stay online for a while. So the idea is to see if the time since this node was brought online in Jenkins has suddenly dropped, and use this as a trigger.

但是,我还没有找到合适的方法来使Jenkins节点最后一次联机.

However, I've not yet found a suitable way to get the time a Jenkins node was last brought online.

推荐答案

我没有测试下面的代码,但是它可以引导您朝着正确的方向发展. 您可以执行Groovy脚本:

I have not tested the code below, but it could lead you in the right direction. You can execute Groovy script:

connectTime = aSlave.getComputer().getConnectTime();

链接:
显示有关节点的信息
Jenkins脚本控制台
确定从属/降下时间

Links:
Display info about nodes
Jenkins Script Console
Determine Slave Up/Down TIme

这篇关于我如何获得Jenkins节点的在线时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆