Search code examples
jenkinsjenkins-cli

How to check jenkins node connection status using jenkins-cli


I'm trying to check specific Jenkins node is connected using Jenkins CLI . To get the node details I can use get-node command and it returns details as this 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>

But it does not includes the node status. Anyone has idea how to check the node status by Jenkins cli


Solution

  • As I'm not aware of a method using , my suggestion is to use the REST API:

    http://jenkins.example.com/computer/:name/api/json
    

    returns JSON data including an offline field.

    You can get an overview over all agents (called computer here) on the following URL:

    http://jenkins.example.com/computer/api/json?pretty=true