我有下一个jenkins API脚本:
import jenkins
import json
import re
server = jenkins.Jenkins('https://jenkins_url', username, password)
nodes = json.dumps(server.get_nodes())
nodes = re.sub('\"offline\"|[:{} \[\]]|true,|false,|\"name\"|\"','',nodes).split(',')
for label in nodes:
if label != 'master':
print label
node_config = server.get_node_config(label)
print node_config
node_config包含例如下一个xml文本:
<?xml version="1.0" encoding="UTF-8"?>
<slave>
<name>test.server</name>
<description></description>
<remoteFS>/var/lib/jenkins</remoteFS>
<numExecutors>1</numExecutors>
<mode>EXCLUSIVE</mode>
<retentionStrategy class="hudson.slaves.RetentionStrategy$Always"/>
<launcher class="hudson.plugins.sshslaves.SSHLauncher" plugin="ssh-slaves@1.10">
<host>test.server</host>
<port>7777</port>
<credentialsId>d0970a8f-d124</credentialsId>
<maxNumRetries>0</maxNumRetries>
<retryWaitTime>0</retryWaitTime>
</launcher>
<label>BuildServer</label>
<nodeProperties/>
<userId>test</userId>
</slave>
我想获得每个标记的值,以便在输出上获得,例如test.server等。
你可以帮帮我吗?
答案 0 :(得分:1)
String locations = data.getJSONArray("results").getJSONObject(0).getJSONArray("lexicalEntries").getJSONObject(0).getJSONArray("entries").getJSONObject(0).getJSONArray("senses").getJSONObject(0).get("definitions").toString();