Skip to content
Permalink
Browse files

Merge pull request #206 from abayer/jenkins-45575-jenkins-49679

[JENKINS-45575, JENKINS-49679] Test multiple assignment CPS fixes
  • Loading branch information...
abayer committed Mar 7, 2018
2 parents 57bda81 + 0c4b3d9 commit 78b137d8743ea3cf80ae302ec89f8aeabf3eb944
Showing with 44 additions and 2 deletions.
  1. +1 −1 Jenkinsfile
  2. +1 −1 pom.xml
  3. +42 −0 src/test/java/org/jenkinsci/plugins/workflow/cps/CpsFlowDefinition2Test.java
@@ -1 +1 @@
buildPlugin(jenkinsVersions: [null, '2.60.3', '2.73.1'])
buildPlugin(jenkinsVersions: [null, '2.73.3'])
@@ -68,7 +68,7 @@
<git-plugin.version>3.1.0</git-plugin.version>
<workflow-support-plugin.version>2.17</workflow-support-plugin.version>
<scm-api-plugin.version>2.0.8</scm-api-plugin.version>
<groovy-cps.version>1.22</groovy-cps.version>
<groovy-cps.version>1.23</groovy-cps.version>
<jenkins-test-harness.version>2.33</jenkins-test-harness.version>
</properties>
<dependencies>
@@ -423,4 +423,46 @@ public void variableDecl() throws Exception {
p.setDefinition(new CpsFlowDefinition("String foo", true));
jenkins.buildAndAssertSuccess(p);
}

@Issue("JENKINS-45575")
@Test
public void multipleAssignmentInSandbox() throws Exception {
WorkflowJob job = jenkins.jenkins.createProject(WorkflowJob.class, "p");
job.setDefinition(new CpsFlowDefinition("def (a, b) = ['first', 'second']\n" +
"def c, d\n" +
"(c, d) = ['third', 'fourth']\n" +
"assert a+b+c+d == 'firstsecondthirdfourth'\n", true));
jenkins.buildAndAssertSuccess(job);
}

@Issue("JENKINS-45575")
@Test
public void multipleAssignmentOutsideSandbox() throws Exception {
WorkflowJob job = jenkins.jenkins.createProject(WorkflowJob.class, "p");
job.setDefinition(new CpsFlowDefinition("def (a, b) = ['first', 'second']\n" +
"def c, d\n" +
"(c, d) = ['third', 'fourth']\n" +
"assert a+b+c+d == 'firstsecondthirdfourth'\n", false));
jenkins.buildAndAssertSuccess(job);
}

@Issue("JENKINS-49679")
@Test
public void multipleAssignmentFunctionCalledOnce() throws Exception {
WorkflowJob job = jenkins.jenkins.createProject(WorkflowJob.class, "p");
job.setDefinition(new CpsFlowDefinition("alreadyRun = false\n" +
"def getAandB() {\n" +
" if (!alreadyRun) {\n" +
" alreadyRun = true\n" +
" return ['first', 'second']\n" +
" } else {\n" +
" return ['bad', 'worse']\n" +
" }\n" +
"}\n" +
"def (a, b) = getAandB()\n" +
"def c, d\n" +
"(c, d) = ['third', 'fourth']\n" +
"assert a+b+c+d == 'firstsecondthirdfourth'\n", true));
jenkins.buildAndAssertSuccess(job);
}
}

0 comments on commit 78b137d

Please sign in to comment.
You can’t perform that action at this time.