Skip to content

Commit 7874aa9

Browse files
authored
Merge pull request #206 from RainerW/crumbOnRunScript
add crumb parameter to runScript
2 parents c1c5245 + fd5ea44 commit 7874aa9

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

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

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,26 @@ public void enableJob(String jobName, boolean crumbFlag) throws IOException {
710710
* @throws IOException
711711
*/
712712
public String runScript(String script) throws IOException {
713-
return client.post_text("/scriptText", "script=" + script, ContentType.APPLICATION_FORM_URLENCODED, false);
713+
return runScript(script,false);
714+
}
715+
716+
/**
717+
* Runs the provided groovy script on the server and returns the result.
718+
*
719+
* This is similar to running groovy scripts using the script console.
720+
*
721+
* In the instance where your script causes an exception, the server still
722+
* returns a 200 status, so detecting errors is very challenging. It is
723+
* recommended to use heuristics to check your return string for stack
724+
* traces by detecting strings like "groovy.lang.(something)Exception".
725+
*
726+
* @param script
727+
* @param crumb enable crumb
728+
* @return results
729+
* @throws IOException
730+
*/
731+
public String runScript(String script,boolean crumb) throws IOException {
732+
return client.post_text("/scriptText", "script=" + script, ContentType.APPLICATION_FORM_URLENCODED, crumb);
714733
}
715734

716735
public Queue getQueue() throws IOException {

0 commit comments

Comments
 (0)