Skip to content

Commit

Permalink
Merge pull request #206 from abayer/jenkins-45575-jenkins-49679
Browse files Browse the repository at this point in the history
[JENKINS-45575, JENKINS-49679] Test multiple assignment CPS fixes
  • Loading branch information
abayer committed Mar 7, 2018
2 parents 57bda81 + 0c4b3d9 commit 78b137d
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Jenkinsfile
@@ -1 +1 @@
buildPlugin(jenkinsVersions: [null, '2.60.3', '2.73.1'])
buildPlugin(jenkinsVersions: [null, '2.73.3'])
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -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>
Expand Down
Expand Up @@ -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.