Skip to content
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
4 changes: 4 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Release 0.3.8 (NOT RELEASED YET)

* [Fixed Issue 289][issue-289]

Added a build.stop() method which takes in a crumbFlag


* [Fixed Issue 301][issue-301]

Expand Down
27 changes: 27 additions & 0 deletions jenkins-client/src/main/java/com/offbytwo/jenkins/model/Build.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,33 @@ public String Stop() throws HttpResponseException, IOException {
return "";
}

/** Stops the build which is currently in progress. This version takes in
* a crumbFlag. In some cases , an error is thrown which reads
* "No valid crumb was included in the request". This stop method is used incase
* those issues occur
*
* @param crumbFlag flag used to specify if a crumb is passed into for the request
* @return the client url
* @throws HttpResponseException
* @throws IOException
*/
public String Stop(boolean crumbFlag) throws HttpResponseException, IOException {
try {

return client.get(url + "stop");
} catch (IOException ex) {
if (((HttpResponseException) ex).getStatusCode() == 405) {
stopPost(crumbFlag);
return "";
}
}
return "";
}

private void stopPost(boolean crumbFlag) throws HttpResponseException, IOException {
client.post(url + "stop", crumbFlag);
}

private void stopPost() throws HttpResponseException, IOException {
client.post(url + "stop");
}
Expand Down