node labels from jenkins api

jenkins

Solution

Apparently, node labels are part of node configuration, so they live in

{base_url}/computer/{node_str}/config.xml

Here is my hack to access that through python jenkinsapi (similar to job configuration), from `node_str`

import xml.etree.ElementTree as ET
from jenkinsapi.jenkins import Jenkins

j = Jenkins(...)
n = j.get_node(node_str)
response = n.jenkins.requester.get_and_confirm_status( "%(baseurl)s/config.xml" % n.__dict__)
_element_tree = ET.fromstring(response.text)
node_labels = _element_tree.find('label').text

Problem

Is there any way I can extract node labels from jenkins API? The standard: ``` {base_url}/computer/{node}/api ``` did not seem to have any label information. Is it in some other place?

Original source