如何使用 jenkins-cli 检查 jenkins 节点连接状态

Nay*_*iya 2 jenkins jenkins-cli

我正在尝试使用Jenkins CLI检查特定的 Jenkins 节点是否已连接 。要获取节点详细信息,我可以使用get-node命令并将详细信息作为此 xml 返回

<?xml version="1.0" encoding="UTF-8"?>
<slave>
<name>20170602_jenkins_slave_002</name>
<description>10.49.82.46</description>
<remoteFS>c:\\jenkins_root</remoteFS>
<numExecutors>1</numExecutors>
<mode>EXCLUSIVE</mode>
<retentionStrategy class="hudson.slaves.RetentionStrategy$Always"/>
<launcher class="hudson.slaves.JNLPLauncher"/>
<label>20170602_jenkins_slave_002</label>
<nodeProperties/>
<userId>admin</userId>
</slave>
Run Code Online (Sandbox Code Playgroud)

但它不包括节点状态。任何人都知道如何通过 Jenkins cli 检查节点状态

Ste*_*ing 5

由于我不知道使用的方法,我的建议是使用 REST API:

http://jenkins.example.com/computer/:name/api/json
Run Code Online (Sandbox Code Playgroud)

返回包含offline字段的JSON 数据。

您可以通过以下 URL获得所有代理(此处称为计算机)的概览:

http://jenkins.example.com/computer/api/json?pretty=true
Run Code Online (Sandbox Code Playgroud)