Skip to content

Commit

Permalink
Update code as scriptler and Jenkins now use oac.fileupload2
Browse files Browse the repository at this point in the history
  • Loading branch information
kinow committed Dec 26, 2024
1 parent 35f71ca commit bcc9a46
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 16 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
<revision>2.8.7</revision>
<changelist>-SNAPSHOT</changelist>
<!-- https://www.jenkins.io/doc/developer/plugin-development/choosing-jenkins-baseline/ -->
<jenkins.baseline>2.479</jenkins.baseline>
<!-- TODO: switch back to the LTS baseline once the CSP fix is in LTS -->
<jenkins.baseline>2.479</jenkins.baseline>
<!-- TODO: switch back to the LTS baseline once the CSP fix is in LTS -->
<!--<jenkins.version>${jenkins.baseline}.1</jenkins.version>-->
<jenkins.version>2.482</jenkins.version>
<!-- jenkins.version>${jenkins.baseline}.1</jenkins.version -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,10 @@
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map.Entry;

import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload2.core.FileItem;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.biouno.unochoice.model.GroovyScript;
Expand Down Expand Up @@ -66,7 +65,7 @@
import hudson.model.ParameterDefinition;
import hudson.model.ParametersDefinitionProperty;
import hudson.model.Result;
import hudson.model.FileParameterValue.FileItemImpl;
import hudson.model.FileParameterValue.FileItemImpl2;
import hudson.model.queue.QueueTaskFuture;

/**
Expand Down Expand Up @@ -110,7 +109,7 @@ public void setUp() throws Exception {
ScriptlerHelper scriptlerHelper = new ScriptlerHelper(scriptler);
scriptFile = Files.createTempFile("uno-choice", "dummy.groovy").toFile();
FileUtils.writeStringToFile(scriptFile, SCRIPT_PARAM001, Charset.defaultCharset(), false);
FileItem fi = new FileItemImpl(scriptFile);
FileItem<?> fi = new FileItemImpl2(scriptFile);
scriptlerHelper.saveScript(fi, true, "dummy.groovy");

scriptler.getConfiguration().getScriptById("dummy.groovy")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
package org.biouno.unochoice.issue63983;

import hudson.model.FileParameterValue;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload2.core.FileItem;
import org.apache.commons.io.FileUtils;
import org.biouno.unochoice.model.ScriptlerScript;
import org.jenkinsci.plugins.scriptler.ScriptlerHelper;
Expand Down Expand Up @@ -64,7 +64,7 @@ public void testGroovyScriptApprovedNoSandboxOK() throws Exception {
"return \"Got instance!\";";
final File scriptFile = Files.createTempFile("uno-choice", "63983").toFile();
FileUtils.writeStringToFile(scriptFile, scriptText, Charset.defaultCharset(), false);
final FileItem fi = new FileParameterValue.FileItemImpl(scriptFile);
final FileItem<?> fi = new FileParameterValue.FileItemImpl2(scriptFile);
scriptlerHelper.saveScript(fi, true, "63983");
Script script = new Script("63983.groovy", "63983.groovy", "A comment.", false, Collections.emptyList(), false);
ScriptlerConfiguration.getConfiguration().addOrReplace(script);
Expand All @@ -88,7 +88,7 @@ public void testGroovyScriptPendingSandboxRejected() throws Exception {
"return \"Got instance!\";";
final File scriptFile = Files.createTempFile("uno-choice", "63983").toFile();
FileUtils.writeStringToFile(scriptFile, scriptText, Charset.defaultCharset(), false);
final FileItem fi = new FileParameterValue.FileItemImpl(scriptFile);
final FileItem<?> fi = new FileParameterValue.FileItemImpl2(scriptFile);
scriptlerHelper.saveScript(fi, true, "63983");
Script script = new Script("63983.groovy", "63983.groovy", "A comment.", false, Collections.emptyList(), false);
ScriptlerConfiguration.getConfiguration().addOrReplace(script);
Expand All @@ -114,7 +114,7 @@ public void testGroovyScriptPendingNoSandboxRejected() throws Exception {
"return \"Got instance!\";";
final File scriptFile = Files.createTempFile("uno-choice", "63983").toFile();
FileUtils.writeStringToFile(scriptFile, scriptText, Charset.defaultCharset(), false);
final FileItem fi = new FileParameterValue.FileItemImpl(scriptFile);
final FileItem<?> fi = new FileParameterValue.FileItemImpl2(scriptFile);
scriptlerHelper.saveScript(fi, true, "63983");
Script script = new Script("63983.groovy", "63983.groovy", "A comment.", false, Collections.emptyList(), false);
ScriptlerConfiguration.getConfiguration().addOrReplace(script);
Expand All @@ -140,7 +140,7 @@ public void testGroovyScriptApprovedSandboxRejected() throws Exception {
"return \"Got instance!\";";
final File scriptFile = Files.createTempFile("uno-choice", "63983").toFile();
FileUtils.writeStringToFile(scriptFile, scriptText, Charset.defaultCharset(), false);
final FileItem fi = new FileParameterValue.FileItemImpl(scriptFile);
final FileItem<?> fi = new FileParameterValue.FileItemImpl2(scriptFile);
scriptlerHelper.saveScript(fi, true, "63983");
Script script = new Script("63983.groovy", "63983.groovy", "A comment.", false, Collections.emptyList(), false);
ScriptlerConfiguration.getConfiguration().addOrReplace(script);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,15 @@
import hudson.model.ParameterDefinition;
import hudson.model.ParametersDefinitionProperty;
import hudson.model.Result;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload2.core.FileItem;
import org.apache.commons.io.FileUtils;
import org.biouno.unochoice.AbstractScriptableParameter;
import org.biouno.unochoice.CascadeChoiceParameter;
import org.biouno.unochoice.model.ScriptlerScript;
import org.jenkinsci.plugins.scriptler.ScriptlerHelper;
import org.jenkinsci.plugins.scriptler.ScriptlerManagement;
import org.jenkinsci.plugins.scriptler.config.Parameter;
import org.jenkinsci.plugins.scriptsecurity.scripts.ScriptApproval;
import org.jenkinsci.plugins.scriptsecurity.scripts.languages.GroovyLanguage;
import org.jenkinsci.plugins.workflow.flow.FlowDefinition;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
import org.junit.Before;
import org.junit.Rule;
Expand Down Expand Up @@ -91,7 +89,7 @@ public void setUp() throws Exception {
ScriptlerHelper scriptlerHelper = new ScriptlerHelper(scriptler);
scriptFile = Files.createTempFile("uno-choice", "Cascade.groovy").toFile();
FileUtils.writeStringToFile(scriptFile, GROOVY_SCRIPT, Charset.defaultCharset(), false);
FileItem fi = new FileParameterValue.FileItemImpl(scriptFile);
FileItem<?> fi = new FileParameterValue.FileItemImpl2(scriptFile);
scriptlerHelper.saveScript(fi, true, "Cascade.groovy");

scriptler.getConfiguration()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
*/
package org.jenkinsci.plugins.scriptler;

import org.apache.commons.fileupload.FileItem;

import org.apache.commons.fileupload2.core.FileItem;

/**
* @see <a href="https://github.com/jenkinsci/scriptler-plugin/blob/5308c27816ed8da5924eedcc6cb12c5655a7e5b3/src/test/java/org/jenkinsci/plugins/scriptler/ScriptlerManagementHelper.java">
Expand Down

0 comments on commit bcc9a46

Please sign in to comment.