Search in sources :

Example 6 with FlowGraphWalker

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

the class CpsScmFlowDefinitionTest method basics.

@Test
public void basics() throws Exception {
    WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
    CpsScmFlowDefinition def = new CpsScmFlowDefinition(new SingleFileSCM("flow.groovy", "echo 'hello from SCM'"), "flow.groovy");
    // currently the default, but just to be clear that we do rely on that in this test
    def.setLightweight(false);
    p.setDefinition(def);
    WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
    // TODO currently the log text is in Run.log, but not on FlowStartNode/LogAction, so not visible from Workflow Steps etc.
    r.assertLogContains("hello from SCM", b);
    r.assertLogContains("Staging flow.groovy", b);
    r.assertLogNotContains("Retrying after 10 seconds", b);
    FlowGraphWalker w = new FlowGraphWalker(b.getExecution());
    int workspaces = 0;
    for (FlowNode n : w) {
        if (n.getAction(WorkspaceAction.class) != null) {
            workspaces++;
        }
    }
    assertEquals(1, workspaces);
}
Also used : WorkspaceAction(org.jenkinsci.plugins.workflow.actions.WorkspaceAction) FlowGraphWalker(org.jenkinsci.plugins.workflow.graph.FlowGraphWalker) SingleFileSCM(org.jvnet.hudson.test.SingleFileSCM) WorkflowJob(org.jenkinsci.plugins.workflow.job.WorkflowJob) WorkflowRun(org.jenkinsci.plugins.workflow.job.WorkflowRun) FlowDurabilityHint(org.jenkinsci.plugins.workflow.flow.FlowDurabilityHint) FlowNode(org.jenkinsci.plugins.workflow.graph.FlowNode) Test(org.junit.Test)

Aggregations

FlowGraphWalker (org.jenkinsci.plugins.workflow.graph.FlowGraphWalker)6 FlowNode (org.jenkinsci.plugins.workflow.graph.FlowNode)6 ArrayList (java.util.ArrayList)2 ErrorAction (org.jenkinsci.plugins.workflow.actions.ErrorAction)2 BlockEndNode (org.jenkinsci.plugins.workflow.graph.BlockEndNode)2 BlockStartNode (org.jenkinsci.plugins.workflow.graph.BlockStartNode)2 WorkflowJob (org.jenkinsci.plugins.workflow.job.WorkflowJob)2 WorkflowRun (org.jenkinsci.plugins.workflow.job.WorkflowRun)2 Test (org.junit.Test)2 Action (hudson.model.Action)1 List (java.util.List)1 JSONArray (net.sf.json.JSONArray)1 JSONObject (net.sf.json.JSONObject)1 WorkspaceAction (org.jenkinsci.plugins.workflow.actions.WorkspaceAction)1 StepEndNode (org.jenkinsci.plugins.workflow.cps.nodes.StepEndNode)1 StepNode (org.jenkinsci.plugins.workflow.cps.nodes.StepNode)1 FlowDurabilityHint (org.jenkinsci.plugins.workflow.flow.FlowDurabilityHint)1 FlowExecution (org.jenkinsci.plugins.workflow.flow.FlowExecution)1 StepNode (org.jenkinsci.plugins.workflow.graph.StepNode)1 StepDescriptor (org.jenkinsci.plugins.workflow.steps.StepDescriptor)1