Skip to content

Commit ed4aae1

Browse files
Chids-gskhmarbaise
authored andcommitted
Fixed# #243 Support for Stopping and Restarting Jenkins (#325)
* Support for Stop and Restarting Jenkins * Updated Release notes * Fixed Link in ReleaseNotes
1 parent 7add859 commit ed4aae1

File tree

2 files changed

+76
-2
lines changed

2 files changed

+76
-2
lines changed

ReleaseNotes.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,12 @@
112112

113113
### API Changes
114114

115-
* ?
116-
115+
* [Fixed Issue 243](https://github.com/jenkinsci/java-client-api/issues/243)
116+
117+
Added new methods to JenkinsServer for stopping and restarting Jenkins. The methods are restart(Boolean crumbFlag), safeRestart(Boolean crumbFlag), exit(Boolean crumbFlag) and safeExit(Boolean crumbFlag)
118+
119+
Thanks for that to [Chids](https://github.com/Chids-gs).
120+
117121
## Release 0.3.7
118122

119123
* Changed Eclipse Formatting configuration.

jenkins-client/src/main/java/com/offbytwo/jenkins/JenkinsServer.java

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -901,4 +901,74 @@ public void close() {
901901
}
902902

903903

904+
/**
905+
* Restart Jenkins without waiting for any existing build to complete
906+
*
907+
* @param crumbFlag
908+
* <code>true</code> to add <b>crumbIssuer</b> <code>false</code>
909+
* otherwise.
910+
* @throws IOException
911+
* in case of an error.
912+
*/
913+
public void restart(Boolean crumbFlag) throws IOException {
914+
try {
915+
client.post("/restart", crumbFlag);
916+
} catch (org.apache.http.client.ClientProtocolException e) {
917+
LOGGER.error("restart()", e);
918+
}
919+
}
920+
921+
/**
922+
* safeRestart: Puts Jenkins into the quiet mode, wait for existing builds
923+
* to be completed, and then restart Jenkins
924+
*
925+
* @param crumbFlag
926+
* <code>true</code> to add <b>crumbIssuer</b> <code>false</code>
927+
* otherwise.
928+
* @throws IOException
929+
* in case of an error.
930+
*/
931+
public void safeRestart(Boolean crumbFlag) throws IOException {
932+
try {
933+
client.post("/safeRestart", crumbFlag);
934+
} catch (org.apache.http.client.ClientProtocolException e) {
935+
LOGGER.error("safeRestart()", e);
936+
}
937+
}
938+
939+
/**
940+
* Shutdown Jenkins without waiting for any existing build to complete
941+
*
942+
* @param crumbFlag
943+
* <code>true</code> to add <b>crumbIssuer</b> <code>false</code>
944+
* otherwise.
945+
* @throws IOException
946+
* in case of an error.
947+
*/
948+
//
949+
public void exit(Boolean crumbFlag) throws IOException {
950+
try {
951+
client.post("/exit", crumbFlag);
952+
} catch (org.apache.http.client.ClientProtocolException e) {
953+
LOGGER.error("exit()", e);
954+
}
955+
}
956+
957+
/**
958+
* safeExit: Puts Jenkins into the quiet mode, wait for existing builds to
959+
* be completed, and then shut down Jenkins
960+
*
961+
* @param crumbFlag
962+
* <code>true</code> to add <b>crumbIssuer</b> <code>false</code>
963+
* otherwise.
964+
* @throws IOException
965+
* in case of an error.
966+
*/
967+
public void safeExit(Boolean crumbFlag) throws IOException {
968+
try {
969+
client.post("/safeExit", crumbFlag);
970+
} catch (org.apache.http.client.ClientProtocolException e) {
971+
LOGGER.error("safeExit()", e);
972+
}
973+
}
904974
}

0 commit comments

Comments
 (0)