This repository has been archived by the owner on Dec 15, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #131 from jenkinsci/user-defined-global-libs
[JENKINS-26135] Allow CPS global lib scripts to define global variables
- Loading branch information
Showing
21 changed files
with
662 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 0 additions & 57 deletions
57
aggregator/src/test/groovy/org/jenkinsci/plugins/workflow/cps/steps/LoadStepTest.groovy
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
aggregator/src/test/java/org/jenkinsci/plugins/workflow/cps/steps/LoadStepTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package org.jenkinsci.plugins.workflow.cps.steps; | ||
|
||
import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition; | ||
import org.jenkinsci.plugins.workflow.job.WorkflowJob; | ||
import org.jenkinsci.plugins.workflow.job.WorkflowRun; | ||
import org.junit.ClassRule; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.jvnet.hudson.test.BuildWatcher; | ||
import org.jvnet.hudson.test.JenkinsRule; | ||
|
||
/** | ||
* | ||
* | ||
* @author Kohsuke Kawaguchi | ||
*/ | ||
public class LoadStepTest { | ||
|
||
@ClassRule public static BuildWatcher buildWatcher = new BuildWatcher(); | ||
@Rule public JenkinsRule r = new JenkinsRule(); | ||
|
||
@Test | ||
public void basics() throws Exception { | ||
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p"); | ||
p.setDefinition(new CpsFlowDefinition( | ||
"node {\n" + | ||
" writeFile text: 'println(21*2)', file: 'test.groovy'\n" + | ||
" println 'something printed'\n" +// make sure that 'println' in groovy script works | ||
" load 'test.groovy'\n" + | ||
"}", true)); | ||
WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0)); | ||
r.assertLogContains("something printed", b); | ||
r.assertLogContains("42", b); | ||
} | ||
|
||
/** | ||
* "evaluate" call is supposed to yield a value | ||
*/ | ||
@Test | ||
public void evaluationResult() throws Exception { | ||
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p"); | ||
p.setDefinition(new CpsFlowDefinition( | ||
"node {\n" + | ||
" writeFile text: '21*2', file: 'test.groovy'\n" + | ||
" def o = load('test.groovy')\n" + | ||
" println 'output=' + o\n" + | ||
"}")); | ||
WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0)); | ||
r.assertLogContains("output=42", b); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.