diff --git a/ReleaseNotes.md b/ReleaseNotes.md index 515a765b..2d3ad6d6 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -2,6 +2,18 @@ ## Release 0.3.8 (NOT RELEASED YET) + * [JENKINS-46472](https://issues.jenkins-ci.org/browse/JENKINS-46472) + + Added ability to modify offline cause for offline computers. + + ```java + ComputerWithDetails computer = ... + if (!computer.getOffline()){ + computer.toggleOffline(); + computer.changeOfflineCause("Scheduled for termination"); + } + ``` + * [JENKINS-46445](https://issues.jenkins-ci.org/browse/JENKINS-46445) Add support for both client TLS and basic authentication. diff --git a/jenkins-client/src/main/java/com/offbytwo/jenkins/model/ComputerWithDetails.java b/jenkins-client/src/main/java/com/offbytwo/jenkins/model/ComputerWithDetails.java index b1df2eef..c565f8a2 100644 --- a/jenkins-client/src/main/java/com/offbytwo/jenkins/model/ComputerWithDetails.java +++ b/jenkins-client/src/main/java/com/offbytwo/jenkins/model/ComputerWithDetails.java @@ -97,6 +97,23 @@ public void toggleOffline() throws IOException { toggleOffline( false ); } + public void changeOfflineCause(String cause, boolean crumbFlag) throws IOException { + String name; + if ("master".equals(displayName)) { + name = "(master)"; + } else { + name = UrlEscapers.urlPathSegmentEscaper().escape(displayName); + } + + Map data = new HashMap(); + data.put( "offlineMessage", cause ); + client.post_form("/computer/" + name + "/changeOfflineCause?", data, crumbFlag); + } + + public void changeOfflineCause(String cause) throws IOException { + changeOfflineCause(cause, false); + } + public Boolean getManualLaunchAllowed() { return manualLaunchAllowed; }