salimfadhley/jenkinsapi — pull request #218 by adamreid (2013-12-02 21:10:41+00:00)
Title: Label feature

Adds a LabelExpression class that is able to parse the label expressions used in job configs and determine matches against a list of labels.

Adds a Label class that queries /label//api for info about jobs and nodes that match

Added get_label_expression and matches_labels functions to Job class. get_label_expression looks at the jobs config.xml for the assignedNode element and parses the text to produce a LabelExpression. matches_labels takes a list of labels and checks if they match the nodes label expression.

Added functionality (suc as used in Job class) to the Node class to load config.xml so that labels for a node can be determined. Added get_labels function that returns a list of Label objects associated with the node. Since node host names are often used as a label, the default behavior is to include it in the list of labels returned, but this may be overridden by calling Node.get_labels(add_host_label=False)

I've added systests and unit tests to cover this functionality. If more tests are needed let me know what needs to be added.