Search in sources :

Example 21 with CpsFlowDefinition

use of org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition in project workflow-cps-plugin by jenkinsci.

the class DSLTest method dollar_class_must_die2.

/**
 * Split arguments between meta step and state
 */
@Issue("JENKINS-29922")
@Test
public void dollar_class_must_die2() throws Exception {
    WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "die2");
    p.setDefinition(new CpsFlowDefinition("california ocean:'pacific', mountain:'sierra', moderate:true", true));
    assertThat(JenkinsRule.getLog(r.assertBuildStatusSuccess(p.scheduleBuild2(0))).replace("\r\n", "\n"), containsString("Introducing california\nCalifornia from pacific to sierra"));
}
Also used : CpsFlowDefinition(org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition) WorkflowJob(org.jenkinsci.plugins.workflow.job.WorkflowJob) Issue(org.jvnet.hudson.test.Issue) Test(org.junit.Test)

Example 22 with CpsFlowDefinition

use of org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition in project workflow-cps-plugin by jenkinsci.

the class DSLTest method monomorphic.

/**
 * Tests the ability to execute a step with an unnamed monomorphic describable argument.
 */
@Issue("JENKINS-29711")
@Test
public void monomorphic() throws Exception {
    WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "mon");
    p.setDefinition(new CpsFlowDefinition("monomorphStep([firstArg:'one', secondArg:'two'])", true));
    r.assertLogContains("First arg: one, second arg: two", r.assertBuildStatusSuccess(p.scheduleBuild2(0)));
    WorkflowRun run = p.getLastBuild();
    LinearScanner scanner = new LinearScanner();
    FlowNode node = scanner.findFirstMatch(run.getExecution().getCurrentHeads(), new NodeStepTypePredicate("monomorphStep"));
    ArgumentsAction argumentsAction = node.getPersistentAction(ArgumentsAction.class);
    Assert.assertNotNull(argumentsAction);
    Assert.assertEquals("one,two", ArgumentsAction.getStepArgumentsAsString(node));
}
Also used : ArgumentsAction(org.jenkinsci.plugins.workflow.actions.ArgumentsAction) NodeStepTypePredicate(org.jenkinsci.plugins.workflow.graphanalysis.NodeStepTypePredicate) CpsFlowDefinition(org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition) WorkflowJob(org.jenkinsci.plugins.workflow.job.WorkflowJob) LinearScanner(org.jenkinsci.plugins.workflow.graphanalysis.LinearScanner) WorkflowRun(org.jenkinsci.plugins.workflow.job.WorkflowRun) FlowNode(org.jenkinsci.plugins.workflow.graph.FlowNode) Issue(org.jvnet.hudson.test.Issue) Test(org.junit.Test)

Example 23 with CpsFlowDefinition

use of org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition in project workflow-cps-plugin by jenkinsci.

the class DSLTest method monomorphicSymbol.

@Issue("JENKINS-29711")
@Test
public void monomorphicSymbol() throws Exception {
    WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "monSymbol");
    p.setDefinition(new CpsFlowDefinition("monomorphWithSymbolStep monomorphSymbol(firstArg: 'one', secondArg: 'two')", true));
    r.assertLogContains("First arg: one, second arg: two", r.assertBuildStatusSuccess(p.scheduleBuild2(0)));
}
Also used : CpsFlowDefinition(org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition) WorkflowJob(org.jenkinsci.plugins.workflow.job.WorkflowJob) Issue(org.jvnet.hudson.test.Issue) Test(org.junit.Test)

Example 24 with CpsFlowDefinition

use of org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition in project workflow-cps-plugin by jenkinsci.

the class DSLTest method monomorphicList.

/**
 * Tests the ability to execute a step with an unnamed monomorphic list argument.
 */
@Issue("JENKINS-29711")
@Test
public void monomorphicList() throws Exception {
    WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "monList");
    p.setDefinition(new CpsFlowDefinition("monomorphListStep([[firstArg:'one', secondArg:'two'], [firstArg:'three', secondArg:'four']])", true));
    WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
    r.assertLogContains("First arg: one, second arg: two", b);
    r.assertLogContains("First arg: three, second arg: four", b);
}
Also used : CpsFlowDefinition(org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition) WorkflowJob(org.jenkinsci.plugins.workflow.job.WorkflowJob) WorkflowRun(org.jenkinsci.plugins.workflow.job.WorkflowRun) Issue(org.jvnet.hudson.test.Issue) Test(org.junit.Test)

Example 25 with CpsFlowDefinition

use of org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition in project workflow-cps-plugin by jenkinsci.

the class CpsStringGroovyMethodsTest method replaceAll.

@Test
public void replaceAll() throws Exception {
    WorkflowJob j = r.createProject(WorkflowJob.class, "replaceAll");
    j.setDefinition(new CpsFlowDefinition("assert 'foobarfoobarfoo'.replaceAll('foo') {\n" + "  it.reverse()\n" + "} == 'oofbaroofbaroof'\n", true));
    r.buildAndAssertSuccess(j);
}
Also used : CpsFlowDefinition(org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition) WorkflowJob(org.jenkinsci.plugins.workflow.job.WorkflowJob) Test(org.junit.Test)

Aggregations

CpsFlowDefinition (org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition)206 Test (org.junit.Test)196 WorkflowJob (org.jenkinsci.plugins.workflow.job.WorkflowJob)168 WorkflowRun (org.jenkinsci.plugins.workflow.job.WorkflowRun)111 Issue (org.jvnet.hudson.test.Issue)63 Map (java.util.Map)60 List (java.util.List)26 FlowNode (org.jenkinsci.plugins.workflow.graph.FlowNode)26 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)22 RunList (hudson.util.RunList)20 ExtensionList (hudson.ExtensionList)19 Statement (org.junit.runners.model.Statement)19 Run (hudson.model.Run)17 URL (java.net.URL)16 AmazonCloudFormation (com.amazonaws.services.cloudformation.AmazonCloudFormation)12 TaskListener (hudson.model.TaskListener)11 CpsFlowExecution (org.jenkinsci.plugins.workflow.cps.CpsFlowExecution)10 NodeStepTypePredicate (org.jenkinsci.plugins.workflow.graphanalysis.NodeStepTypePredicate)9 DescribeChangeSetResult (com.amazonaws.services.cloudformation.model.DescribeChangeSetResult)7 Parameter (com.amazonaws.services.cloudformation.model.Parameter)6