Skip to content

Commit

Permalink
Merge pull request #313 from zelahi/master
Browse files Browse the repository at this point in the history
Fixed Issue#289 Add a Build.stopPost with a crumbFlag version
  • Loading branch information
khmarbaise authored Feb 17, 2018
2 parents 5150a86 + 1f2c71b commit 5b19702
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
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

0 comments on commit 5b19702

Please sign in to comment.