Skip to content

Commit

Permalink
[FIXED JENKINS-19988] Changes to script parameters in Run Script wind…
Browse files Browse the repository at this point in the history
…ow affect permanent definitions
  • Loading branch information
imod committed Feb 22, 2014
1 parent 739e386 commit 5c1d2f0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
Expand Up @@ -456,13 +456,13 @@ public void doTriggerScript(StaplerRequest req, StaplerResponse rsp, @QueryParam
final boolean isChangeScriptAllowed = isAdmin || allowRunScriptEdit();

if (!isChangeScriptAllowed) {
tempScript = ScriptHelper.getScript(id, true);
tempScript = ScriptHelper.getScriptCopy(id, true);
// use original script, user has no permission to change it!s
scriptSrc = tempScript.script;
} else {
// set the script info back to the request, to display it together with
// the output.
tempScript = ScriptHelper.getScript(id, false);
tempScript = ScriptHelper.getScriptCopy(id, false);
tempScript.setScript(scriptSrc);
}

Expand Down
Expand Up @@ -93,6 +93,10 @@ public Script(String id, String name, String comment, String originCatalog, Stri
this.onlyMaster = onlyMaster;
}

public Script copy() {
return new Script(id, name, comment, originCatalog, originScript, originDate, nonAdministerUsing, parameters, onlyMaster);
}

/*
* (non-Javadoc)
*
Expand Down
Expand Up @@ -48,6 +48,11 @@ public class ScriptHelper {
JSON_CLASS_MAPPING.put("parameters", Parameter.class);
}

public static Script getScriptCopy(String id, boolean withSrc) {
final Script orig = getScript(id, withSrc);
return orig.copy();
}

/**
* Loads the script information.
*
Expand Down

0 comments on commit 5c1d2f0

Please sign in to comment.