Examples of CpsFlowDefinition


Examples of org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition

    @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 {dir('subdir') {sh 'pwd'}}"));
        r.assertLogContains("/subdir", r.assertBuildStatusSuccess(p.scheduleBuild2(0)));
    }
View Full Code Here

Examples of org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition

    @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 {sh 'echo hello > f1'; def text = readFile 'f1'; text = text.toUpperCase(); writeFile file: 'f2', text: text; sh 'cat f2'}"));
        r.assertLogContains("HELLO", r.assertBuildStatusSuccess(p.scheduleBuild2(0)));
    }
View Full Code Here

Examples of org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition

        //                                (restart)
        // (above are the semaphores we must signal)
        story.addStep(new Statement() {
            @Override public void evaluate() throws Throwable {
                WorkflowJob p = story.j.jenkins.createProject(WorkflowJob.class, "demo");
                p.setDefinition(new CpsFlowDefinition(
                        "stage(name: 'A', concurrency: 2);\n" +
                        "echo('in A');\n" +
                        "semaphore('B');\n" +
                        "stage(name: 'B', concurrency: 1);\n" +
                        "echo('in B');\n" +
View Full Code Here

Examples of org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition

    @Rule public JenkinsRule r = new JenkinsRule();

    @Test public void artifactArchiver() throws Exception {
        WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
        p.setDefinition(new CpsFlowDefinition("node {sh 'touch x.txt'; step([$class: 'ArtifactArchiver', artifacts: 'x.txt', fingerprint: true])}"));
        WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
        List<WorkflowRun.Artifact> artifacts = b.getArtifacts();
        assertEquals(1, artifacts.size());
        assertEquals("x.txt", artifacts.get(0).relativePath);
        Fingerprinter.FingerprintAction fa = b.getAction(Fingerprinter.FingerprintAction.class);
View Full Code Here

Examples of org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition

        assertEquals("[x.txt]", fa.getRecords().keySet().toString());
    }

    @Test public void fingerprinter() throws Exception {
        WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
        p.setDefinition(new CpsFlowDefinition("node {sh 'touch x.txt'; step([$class: 'Fingerprinter', targets: 'x.txt'])}"));
        WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
        Fingerprinter.FingerprintAction fa = b.getAction(Fingerprinter.FingerprintAction.class);
        assertNotNull(fa);
        assertEquals("[x.txt]", fa.getRecords().keySet().toString());
    }
View Full Code Here

Examples of org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition

        assertEquals("[x.txt]", fa.getRecords().keySet().toString());
    }

    @Test public void junitResultArchiver() throws Exception {
        WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
        p.setDefinition(new CpsFlowDefinition(
                  "node {\n"
                // Quote hell! " is Java, ''' is Groovy, ' is shell, \" is " inside XML
                + "    sh '''echo '<testsuite name=\"a\"><testcase name=\"a1\"/><testcase name=\"a2\"><error>a2 failed</error></testcase></testsuite>' > a.xml'''\n"
                + "    sh '''echo '<testsuite name=\"b\"><testcase name=\"b1\"/><testcase name=\"b2\"/></testsuite>' > b.xml'''\n"
                + "    step([$class: 'JUnitResultArchiver', testResults: '*.xml'])\n"
 
View Full Code Here

Examples of org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition

        assertEquals(1, a.getFailCount());
    }

    @Test public void javadoc() throws Exception {
        WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
        p.setDefinition(new CpsFlowDefinition(
                  "node {\n"
                + "    sh 'mkdir docs && echo hello world > docs/index.html'\n"
                + "    step([$class: 'JavadocArchiver', javadocDir: 'docs'])\n"
                + "}"));
        r.assertBuildStatusSuccess(p.scheduleBuild2(0));
View Full Code Here

Examples of org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition

    }

    @Test public void mailer() throws Exception {
        WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
        String recipient = "test@nowhere.net";
        p.setDefinition(new CpsFlowDefinition(
                  "node {\n"
                + "    sh '''echo '<testsuite name=\"s\"><testcase name=\"c\"><error>failed</error></testcase></testsuite>' > r.xml'''\n"
                + "    step([$class: 'JUnitResultArchiver', testResults: 'r.xml'])\n"
                + "    step([$class: 'Mailer', recipients: '" + recipient + "'])\n"
                + "}"));
        Mailbox inbox = Mailbox.get(new InternetAddress(recipient));
        inbox.clear();
        WorkflowRun b = r.assertBuildStatus(Result.UNSTABLE, p.scheduleBuild2(0).get());
        assertEquals(JenkinsRule.getLog(b), 1, inbox.size());
        assertEquals(/* MailSender.createUnstableMail/getSubject */Messages.MailSender_UnstableMail_Subject() + " " + b.getFullDisplayName(), inbox.get(0).getSubject());
        p.setDefinition(new CpsFlowDefinition(
                  "node {\n"
                + "    catchError {sh 'false'}\n"
                + "    step([$class: 'Mailer', recipients: '" + recipient + "'])\n"
                + "}"));
        inbox.clear();
View Full Code Here

Examples of org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition

    @Test public void demo() throws Exception {
        story.addStep(new Statement() {
            @Override
            public void evaluate() throws Throwable {
                p = jenkins().createProject(WorkflowJob.class, "demo");
                p.setDefinition(new CpsFlowDefinition("watch(new File('" + jenkins().getRootDir() + "/touch'))"));
                startBuilding();
                waitForWorkflowToSuspend();
                assertTrue(b.isBuilding());
                assertFalse(jenkins().toComputer().isIdle());
            }
View Full Code Here

Examples of org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition

                jenkins().setNumExecutors(0);
                DumbSlave s = createSlave(story.j);
                String nodeName = s.getNodeName();

                p = jenkins().createProject(WorkflowJob.class, "demo");
                p.setDefinition(new CpsFlowDefinition(
                    "def s = jenkins.model.Jenkins.instance.getComputer('" + nodeName + "')\n" +
                    "def r = s.node.rootPath\n" +
                    "def p = r.getRemote()\n" +

                    "watch(new File('" + jenkins().getRootDir() + "/touch'))\n" +
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.