Skip to content

Commit

Permalink
Merge pull request #133 from basil/sandbox
Browse files Browse the repository at this point in the history
Consistently use sandbox for CpsFlowDefinitions
  • Loading branch information
dwnusbaum authored Jul 22, 2019
2 parents a3f4f9e + 758059b commit 86dfc3f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class CLITest {

@Test public void listChanges() throws Exception {
WorkflowJob p = r.createProject(WorkflowJob.class, "p");
p.setDefinition(new CpsFlowDefinition("node {def s = new org.jvnet.hudson.test.FakeChangeLogSCM(); s.addChange().withAuthor('alice').withMsg('hello'); checkout s}", false));
p.setDefinition(new CpsFlowDefinition("node {def s = new org.jvnet.hudson.test.FakeChangeLogSCM(); s.addChange().withAuthor('alice').withMsg('hello'); checkout s}", false /* for org.jvnet.hudson.test.FakeChangeLogSCM */));
r.buildAndAssertSuccess(p);
CLICommandInvoker.Result res = new CLICommandInvoker(r, "list-changes").invokeWithArgs("p", "1");
assertThat(res, CLICommandInvoker.Matcher.succeeded());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@ public class WorkflowJobTest {
p.setDefinition(new CpsFlowDefinition(
"node {\n" +
" checkout(new hudson.scm.NullSCM())\n" +
"}"));
"}", false /* for hudson.scm.NullSCM */));
assertTrue("No runs has been performed and there should be no SCMs", p.getSCMs().isEmpty());

j.buildAndAssertSuccess(p);

assertEquals("Expecting one SCM", 1, p.getSCMs().size());

p.setDefinition(new CpsFlowDefinition("error 'Fail!'"));
p.setDefinition(new CpsFlowDefinition("error 'Fail!'", true));

j.assertBuildStatus(Result.FAILURE, p.scheduleBuild2(0));

assertEquals("Expecting one SCM even though last run failed",1, p.getSCMs().size());

p.setDefinition(new CpsFlowDefinition("echo 'Pass!'"));
p.setDefinition(new CpsFlowDefinition("echo 'Pass!'", true));

j.buildAndAssertSuccess(p);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public class WorkflowRunTest {

@Test public void basics() throws Exception {
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
p.setDefinition(new CpsFlowDefinition("println('hello')"));
p.setDefinition(new CpsFlowDefinition("println('hello')", true));
WorkflowRun b1 = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
assertFalse(b1.isBuilding());
assertFalse(b1.isInProgress());
Expand Down Expand Up @@ -150,8 +150,8 @@ public void iconColor() throws Exception {
p.setDefinition(new CpsFlowDefinition(
"println('hello')\n"+
"semaphore 'wait'\n"+
"println('hello')\n"
));
"println('hello')\n",
true));

// no build exists yet
assertSame(p.getIconColor(),BallColor.NOTBUILT);
Expand Down Expand Up @@ -227,7 +227,7 @@ private void assertColor(WorkflowRun b, BallColor color) throws IOException {
final WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
final String groovy = "println 'hello'";
try (ACLContext context = ACL.as(User.getById("dev", true))) {
p.setDefinition(new CpsFlowDefinition(groovy));
p.setDefinition(new CpsFlowDefinition(groovy, false /* for mock authorization strategy */));
}
r.assertLogContains("UnapprovedUsageException", r.assertBuildStatus(Result.FAILURE, p.scheduleBuild2(0).get()));
Set<ScriptApproval.PendingScript> pendingScripts = ScriptApproval.get().getPendingScripts();
Expand All @@ -248,8 +248,8 @@ public void failedToStartRun() throws Exception {
"def hello = new HelloWorld()\n" +
"public class HelloWorld()\n" +
"{ // <- invalid class definition }\n" +
"}}"
));
"}}",
true));
QueueTaskFuture<WorkflowRun> workflowRunQueueTaskFuture = p.scheduleBuild2(0);
WorkflowRun run = r.assertBuildStatus(Result.FAILURE, workflowRunQueueTaskFuture.get());

Expand All @@ -264,7 +264,7 @@ public void failedToStartRun() throws Exception {
@Test public void buildRecordAfterRename() throws Exception {
{
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p1");
p.setDefinition(new CpsFlowDefinition("echo 'hello world'"));
p.setDefinition(new CpsFlowDefinition("echo 'hello world'", true));
r.assertBuildStatusSuccess(p.scheduleBuild2(0));
p.renameTo("p2");
}
Expand Down Expand Up @@ -372,7 +372,7 @@ public void culprits() throws Exception {
" def thirdScm = new FakeChangeLogSCM()\n" +
" thirdScm.addChange().withAuthor(/charlie$BUILD_NUMBER/)\n" +
" checkout(thirdScm)\n" +
"}\n", false));
"}\n", false /* for org.jvnet.hudson.test.FakeChangeLogSCM */));

WorkflowRun b1 = p.scheduleBuild2(0).waitForStart();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class DurabilityHintJobPropertyTest {
@Test
public void configRoundTripAndRun() throws Exception{
WorkflowJob defaultCase = r.jenkins.createProject(WorkflowJob.class, "testCase");
defaultCase.setDefinition(new CpsFlowDefinition("echo 'cheese is delicious'", false));
defaultCase.setDefinition(new CpsFlowDefinition("echo 'cheese is delicious'", true));

assertNull(defaultCase.getProperty(DurabilityHintJobProperty.class));

Expand Down

0 comments on commit 86dfc3f

Please sign in to comment.