Skip to content

Commit

Permalink
[JENKINS-38268] Testing for lexical closure scope
Browse files Browse the repository at this point in the history
  • Loading branch information
abayer committed Jun 13, 2017
1 parent d897ac0 commit 102b15e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -174,7 +174,7 @@
<dependency>
<groupId>com.cloudbees</groupId>
<artifactId>groovy-cps</artifactId>
<version>1.14</version>
<version>1.15-20170613.134927-2</version> <!-- switch to release once https://github.com/cloudbees/groovy-cps/pull/61 is merged and released -->
</dependency>
<dependency>
<groupId>org.jenkins-ci.ui</groupId>
Expand Down
Expand Up @@ -466,4 +466,25 @@ public void invisibleParallelBranch() throws Exception {
});
}

@Issue("JENKINS-38268")
@Test
public void parallelLexicalScope() throws Exception {
story.addStep(new Statement() {
@Override public void evaluate() throws Throwable {
p = jenkins().createProject(WorkflowJob.class, "p");
p.setDefinition(new CpsFlowDefinition("def fn = { arg ->\n" +
" arg.count = arg.count + 1;\n" +
"}\n" +
"def a = [ id: 'a', count : 0 ];\n" +
"def b = [ id: 'b', count : 0 ];\n" +
"parallel(\n" +
" StepA : { fn(a); },\n" +
" StepB : { fn(b); },\n" +
");\n" +
"assert a.count == 1;\n" +
"assert b.count == 1;\n", true));
story.j.buildAndAssertSuccess(p);
}
});
}
}

0 comments on commit 102b15e

Please sign in to comment.