pycontribs / jenkinsapi

A Python API for accessing resources and configuring Hudson & Jenkins continuous-integration servers
http://pypi.python.org/pypi/jenkinsapi
MIT License
857 stars 483 forks source link

Method "get_nodes" in init gets wrong name for master node #827

Closed xBudii closed 1 year ago

xBudii commented 1 year ago
ISSUE TYPE
Jenkinsapi 0.3.11
Jenkins 2.332.4
SUMMARY

In the init file when get_nodes() is being called, the resulting list of nodes contains a false master node name, in my case it was "Built-In Node" as the return call accesses "displayName" from the returned request call.

EXPECTED RESULTS

[{'name': 'master', 'offline': False}, ...]

ACTUAL RESULTS

[{'name': 'Built-In Node', 'offline': False}, ...]

USEFUL INFORMATION

I think the issue is related to the change that occured when Jenkins gets updated to a newer version. (Please correct me if i am wrong)

Workaround (for me, dont know if it works for everyone): In get_nodes i changed the line: return [{'name': c["displayName"], 'offline': c["offline"]} to return [{'name': c["assignedLabels"][0]["name"] if c["assignedLabels"][0]["name"] == "master" else c["displayName"], 'offline': c["offline"]}

lechat commented 1 year ago

This is now fixed in release 0.3.12