Skip to content

Commit fd5ea44

Browse files
committed
add crumb parameter to runScript
1 parent 50023d2 commit fd5ea44

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
@@ -708,7 +708,26 @@ public void enableJob(String jobName, boolean crumbFlag) throws IOException {
708708
* @throws IOException
709709
*/
710710
public String runScript(String script) throws IOException {
711-
return client.post_text("/scriptText", "script=" + script, ContentType.APPLICATION_FORM_URLENCODED, false);
711+
return runScript(script,false);
712+
}
713+
714+
/**
715+
* Runs the provided groovy script on the server and returns the result.
716+
*
717+
* This is similar to running groovy scripts using the script console.
718+
*
719+
* In the instance where your script causes an exception, the server still
720+
* returns a 200 status, so detecting errors is very challenging. It is
721+
* recommended to use heuristics to check your return string for stack
722+
* traces by detecting strings like "groovy.lang.(something)Exception".
723+
*
724+
* @param script
725+
* @param crumb enable crumb
726+
* @return results
727+
* @throws IOException
728+
*/
729+
public String runScript(String script,boolean crumb) throws IOException {
730+
return client.post_text("/scriptText", "script=" + script, ContentType.APPLICATION_FORM_URLENCODED, crumb);
712731
}
713732

714733
public Queue getQueue() throws IOException {

0 commit comments

Comments
 (0)