Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 376
Nayana Adassuriya Avatar asked Oct 15 '25 14:10

Nayana Adassuriya


1 Answers

As I'm not aware of a method using jenkins-cli, 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
like image 156
StephenKing Avatar answered Oct 18 '25 22:10

StephenKing