Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing against workflow-cps 2.67 #67

Merged
merged 3 commits into from
Apr 24, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
buildPlugin(jenkinsVersions: [null, '2.138.1'])
buildPlugin(configurations: buildPlugin.recommendedConfigurations())
26 changes: 19 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>3.28</version>
<version>3.42</version>
<relativePath />
</parent>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
Expand Down Expand Up @@ -64,20 +64,27 @@
<properties>
<revision>2.14</revision>
<changelist>-SNAPSHOT</changelist>
<jenkins.version>2.107.3</jenkins.version>
<jenkins.version>2.121.1</jenkins.version>
<java.level>8</java.level>
<workflow-cps-plugin.version>2.57</workflow-cps-plugin.version>
<workflow-cps-plugin.version>2.67</workflow-cps-plugin.version>
<git-plugin.version>3.6.4</git-plugin.version>
<scm-api-plugin.version>2.2.7</scm-api-plugin.version>
<workflow-scm-step-plugin.version>2.4</workflow-scm-step-plugin.version>
<workflow-multibranch-plugin.version>2.10</workflow-multibranch-plugin.version>
<workflow-step-api-plugin.version>2.19</workflow-step-api-plugin.version>
<workflow-support-plugin.version>3.2</workflow-support-plugin.version>
</properties>
<dependencies>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-cps</artifactId>
<version>${workflow-cps-plugin.version}</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-step-api</artifactId>
<version>${workflow-step-api-plugin.version}</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>git-server</artifactId>
Expand Down Expand Up @@ -112,12 +119,12 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>script-security</artifactId>
<version>1.46</version>
<version>1.58</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>structs</artifactId>
<version>1.15</version>
<version>1.17</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
Expand All @@ -137,7 +144,12 @@
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-support</artifactId>
<version>2.17</version>
<version>${workflow-support-plugin.version}</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-support</artifactId>
<version>${workflow-support-plugin.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
Expand Down Expand Up @@ -182,7 +194,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-step-api</artifactId>
<version>2.13</version>
<version>${workflow-step-api-plugin.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

package org.jenkinsci.plugins.workflow.libs;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import hudson.AbortException;
import hudson.Extension;
import hudson.ExtensionList;
Expand Down Expand Up @@ -122,6 +123,7 @@ private static <T> T retrySCMOperation(TaskListener listener, Callable<T> task)
return ret;
}

@SuppressFBWarnings(value = "RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE", justification = "apparently bogus complaint about redundant nullcheck in try-with-resources")
static void doRetrieve(String name, boolean changelog, @Nonnull SCM scm, FilePath target, Run<?, ?> run, TaskListener listener) throws Exception {
// Adapted from CpsScmFlowDefinition:
SCMStep delegate = new GenericSCMStep(scm);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,7 @@ public class GrapeTest {
"new ArrayIntList()", true));
// Even assuming signature approvals, we do not want to allow Grape to be used from sandboxed scripts.
ScriptApproval.get().approveSignature("new org.apache.commons.collections.primitives.ArrayIntList");
// Specifically: java.lang.RuntimeException: No suitable ClassLoader found for grab
story.j.assertLogContains("GrapeIvy.chooseClassLoader", story.j.assertBuildStatus(Result.FAILURE, p.scheduleBuild2(0)));
story.j.assertLogContains("WorkflowScript: 1: unable to resolve class org.apache.commons.collections.primitives.ArrayIntList", story.j.assertBuildStatus(Result.FAILURE, p.scheduleBuild2(0)));
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.io.File;
import java.net.URL;
import java.util.Collection;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;

public class WorkflowLibRepositoryLocalTest extends Assert {
@Rule
Expand Down Expand Up @@ -60,8 +61,9 @@ public void initialRepoShouldBeEmpty() throws Exception {
git.push().call();

// test if this script is accessible from form validation
assertEquals(cfdd.doCheckScriptCompile("import org.acme.Foo"), CpsFlowDefinitionValidator.CheckStatus.SUCCESS.asJSON());
assertNotEquals(cfdd.doCheckScriptCompile("import org.acme.NoSuchThing").toString(), CpsFlowDefinitionValidator.CheckStatus.SUCCESS.asJSON().toString()); // control test
WorkflowJob p = j.createProject(WorkflowJob.class);
assertEquals(cfdd.doCheckScriptCompile(p, "import org.acme.Foo"), CpsFlowDefinitionValidator.CheckStatus.SUCCESS.asJSON());
assertNotEquals(cfdd.doCheckScriptCompile(p, "import org.acme.NoSuchThing").toString(), CpsFlowDefinitionValidator.CheckStatus.SUCCESS.asJSON().toString()); // control test
// valid from script-security point of view
assertSame(cfdd.doCheckScript("import org.acme.Foo", true), FormValidation.ok());
assertSame(cfdd.doCheckScript("import org.acme.NoSuchThing", true), FormValidation.ok());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,7 @@ public class FolderLibrariesTest {
WorkflowJob p = d.createProject(WorkflowJob.class, "p");
p.setDefinition(new CpsFlowDefinition("@Library('grape@master') import pkg.Wrapper; echo(/should not have been able to run ${pkg.Wrapper.list()}/)", true));
ScriptApproval.get().approveSignature("new org.apache.commons.collections.primitives.ArrayIntList");
// Groovy 1: java.lang.RuntimeException: No suitable ClassLoader found for grab (within groovy.grape.GrapeIvy.chooseClassLoader)
// Groovy 2: org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: Scripts not permitted to use staticMethod groovy.grape.Grape grab java.util.Map java.util.Map[]
r.assertLogContains("groovy.grape.Grape", r.assertBuildStatus(Result.FAILURE, p.scheduleBuild2(0)));
r.assertLogContains("Wrapper.groovy: 2: unable to resolve class org.apache.commons.collections.primitives.ArrayIntList", r.assertBuildStatus(Result.FAILURE, p.scheduleBuild2(0)));
}

@Issue("JENKINS-43019")
Expand Down