Skip to content

Commit 752c3b9

Browse files
Jesper Terkelsenkhmarbaise
authored andcommitted
JENKINS-56186 Support for showing node labels via java API (#388)
This information is already available in the API call.
1 parent 0f1a8bc commit 752c3b9

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

ReleaseNotes.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,17 @@
5454

5555
Add the crumbFlag as the 2nd parameter of getConsoleOutputText method
5656

57+
* [JENKINS-56186][jissue-56186]
58+
59+
Added labels to computers
60+
61+
```java
62+
ComputerWithDetails computer = ...
63+
for (ComputerLabel assignedLabel : computer.getAssignedLabels()) {
64+
assignedLabel.getName()
65+
}
66+
```
67+
5768
## Release 0.3.8
5869

5970
* [Fixed Issue 289][issue-289]
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.offbytwo.jenkins.model;
2+
3+
public class ComputerLabel {
4+
private String name;
5+
6+
public String getName() {
7+
return name;
8+
}
9+
10+
@Override
11+
public int hashCode() {
12+
final int prime = 31;
13+
int result = 1;
14+
result = prime * result + ((name == null) ? 0 : name.hashCode());
15+
return result;
16+
}
17+
18+
@Override
19+
public boolean equals(Object obj) {
20+
if (this == obj)
21+
return true;
22+
if (obj == null)
23+
return false;
24+
if (getClass() != obj.getClass())
25+
return false;
26+
ComputerLabel other = (ComputerLabel) obj;
27+
if (name == null) {
28+
if (other.name != null)
29+
return false;
30+
} else if (!name.equals(other.name))
31+
return false;
32+
return true;
33+
}
34+
}

jenkins-client/src/main/java/com/offbytwo/jenkins/model/ComputerWithDetails.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public class ComputerWithDetails extends Computer {
1818
private String displayName;
1919
private List actions; //TODO: What kind of List?
2020
private List<Executor> executors;
21+
private List<ComputerLabel> assignedLabels;
2122
private Boolean idle;
2223
private Boolean jnlp;
2324
private Boolean launchSupported;
@@ -46,6 +47,10 @@ public List<Executor> getExecutors() {
4647
return executors;
4748
}
4849

50+
public List<ComputerLabel> getAssignedLabels() {
51+
return assignedLabels;
52+
}
53+
4954
public Boolean getIdle() {
5055
return idle;
5156
}
@@ -169,6 +174,11 @@ public boolean equals(Object obj) {
169174
return false;
170175
} else if (!executors.equals(other.executors))
171176
return false;
177+
if (assignedLabels == null) {
178+
if (other.assignedLabels != null)
179+
return false;
180+
} else if (!assignedLabels.equals(other.assignedLabels))
181+
return false;
172182
if (idle == null) {
173183
if (other.idle != null)
174184
return false;

0 commit comments

Comments
 (0)