Skip to content

JENKINS-56186 Support for showing node labels via java API #388

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@

* ...

* [JENKINS-56186][jissue-56186]

Added labels to computers

```java
ComputerWithDetails computer = ...
for (ComputerLabel assignedLabel : computer.getAssignedLabels()) {
assignedLabel.getName()
}
```

## Release 0.3.8

* [Fixed Issue 289][issue-289]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.offbytwo.jenkins.model;

public class ComputerLabel {
private String name;

public String getName() {
return name;
}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((name == null) ? 0 : name.hashCode());
return result;
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
ComputerLabel other = (ComputerLabel) obj;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
return false;
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class ComputerWithDetails extends Computer {
private String displayName;
private List actions; //TODO: What kind of List?
private List<Executor> executors;
private List<ComputerLabel> assignedLabels;
private Boolean idle;
private Boolean jnlp;
private Boolean launchSupported;
Expand Down Expand Up @@ -46,6 +47,10 @@ public List<Executor> getExecutors() {
return executors;
}

public List<ComputerLabel> getAssignedLabels() {
return assignedLabels;
}

public Boolean getIdle() {
return idle;
}
Expand Down Expand Up @@ -170,6 +175,11 @@ public boolean equals(Object obj) {
return false;
} else if (!executors.equals(other.executors))
return false;
if (assignedLabels == null) {
if (other.assignedLabels != null)
return false;
} else if (!assignedLabels.equals(other.assignedLabels))
return false;
if (idle == null) {
if (other.idle != null)
return false;
Expand Down