Skip to content

Commit 5b19702

Browse files
authored
Merge pull request #313 from zelahi/master
Fixed Issue#289 Add a Build.stopPost with a crumbFlag version
2 parents 5150a86 + 1f2c71b commit 5b19702

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

ReleaseNotes.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Release 0.3.8 (NOT RELEASED YET)
44

5+
* [Fixed Issue 289][issue-289]
6+
7+
Added a build.stop() method which takes in a crumbFlag
8+
59

610
* [Fixed Issue 301][issue-301]
711

jenkins-client/src/main/java/com/offbytwo/jenkins/model/Build.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,33 @@ public String Stop() throws HttpResponseException, IOException {
149149
return "";
150150
}
151151

152+
/** Stops the build which is currently in progress. This version takes in
153+
* a crumbFlag. In some cases , an error is thrown which reads
154+
* "No valid crumb was included in the request". This stop method is used incase
155+
* those issues occur
156+
*
157+
* @param crumbFlag flag used to specify if a crumb is passed into for the request
158+
* @return the client url
159+
* @throws HttpResponseException
160+
* @throws IOException
161+
*/
162+
public String Stop(boolean crumbFlag) throws HttpResponseException, IOException {
163+
try {
164+
165+
return client.get(url + "stop");
166+
} catch (IOException ex) {
167+
if (((HttpResponseException) ex).getStatusCode() == 405) {
168+
stopPost(crumbFlag);
169+
return "";
170+
}
171+
}
172+
return "";
173+
}
174+
175+
private void stopPost(boolean crumbFlag) throws HttpResponseException, IOException {
176+
client.post(url + "stop", crumbFlag);
177+
}
178+
152179
private void stopPost() throws HttpResponseException, IOException {
153180
client.post(url + "stop");
154181
}

0 commit comments

Comments
 (0)