Search in sources :

Example 1 with SingleFileSCM

use of org.jvnet.hudson.test.SingleFileSCM 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) FlowNode(org.jenkinsci.plugins.workflow.graph.FlowNode) Test(org.junit.Test)

Example 2 with SingleFileSCM

use of org.jvnet.hudson.test.SingleFileSCM in project sonar-scanner-jenkins by SonarSource.

the class SonarTestCase method setupSonarMavenProject.

protected MavenModuleSet setupSonarMavenProject(String pomName) throws Exception {
    final MavenModuleSet project = j.jenkins.createProject(MavenModuleSet.class, "MavenProject");
    // Setup SCM
    project.setScm(new SingleFileSCM(pomName, getClass().getResource("/hudson/plugins/sonar/SonarTestCase/pom.xml")));
    // Setup Maven
    project.setRootPOM(pomName);
    project.setGoals("clean install");
    project.setIsArchivingDisabled(true);
    // Setup Sonar
    project.getPublishersList().add(newSonarPublisherForMavenProject());
    return project;
}
Also used : SingleFileSCM(org.jvnet.hudson.test.SingleFileSCM) MavenModuleSet(hudson.maven.MavenModuleSet)

Aggregations

SingleFileSCM (org.jvnet.hudson.test.SingleFileSCM)2 MavenModuleSet (hudson.maven.MavenModuleSet)1 WorkspaceAction (org.jenkinsci.plugins.workflow.actions.WorkspaceAction)1 FlowGraphWalker (org.jenkinsci.plugins.workflow.graph.FlowGraphWalker)1 FlowNode (org.jenkinsci.plugins.workflow.graph.FlowNode)1 WorkflowJob (org.jenkinsci.plugins.workflow.job.WorkflowJob)1 WorkflowRun (org.jenkinsci.plugins.workflow.job.WorkflowRun)1 Test (org.junit.Test)1