Package org.jenkinsci.plugins.workflow.cps

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


                DumbSlave s = createSlave(story.j);
                s.setLabelString("remote quick");
                s.getNodeProperties().add(new EnvironmentVariablesNodeProperty(new EnvironmentVariablesNodeProperty.Entry("ONSLAVE", "true")));

                p = jenkins().createProject(WorkflowJob.class, "demo");
                p.setDefinition(new CpsFlowDefinition(
                    "node('" + s.getNodeName() + "') {\n" +
                    // TODO this has been observed to print the basename command, but not echo the result; why?
                    "    sh('echo before=`basename $PWD`')\n" +
                    "    sh('echo ONSLAVE=$ONSLAVE')\n" +
View Full Code Here


    @Test public void buildShellScriptOnSlaveWithDifferentResumePoint() throws Exception {
        story.addStep(new Statement() {
            @Override public void evaluate() throws Throwable {
                p = jenkins().createProject(WorkflowJob.class, "demo");
                String script = "node {watch(new File('" + jenkins().getRootDir() + "/touch'))}";
                p.setDefinition(new CpsFlowDefinition(script));
                startBuilding();
                waitForWorkflowToSuspend();
                // intentionally not waiting for watch step to begin
            }
        });
View Full Code Here

                startJnlpProc();
                p = story.j.jenkins.createProject(WorkflowJob.class, "demo");
                File f1 = new File(story.j.jenkins.getRootDir(), "f1");
                File f2 = new File(story.j.jenkins.getRootDir(), "f2");
                new FileOutputStream(f1).close();
                p.setDefinition(new CpsFlowDefinition(
                    "node('dumbo') {\n" +
                    "    sh 'touch \"" + f2 + "\"; while [ -f \"" + f1 + "\" ]; do sleep 1; done; echo finished waiting; rm \"" + f2 + "\"'\n" +
                    "    echo 'OK, done'\n" +
                    "}"));
                startBuilding();
View Full Code Here

                startJnlpProc();
                p = story.j.jenkins.createProject(WorkflowJob.class, "demo");
                File f1 = new File(story.j.jenkins.getRootDir(), "f1");
                File f2 = new File(story.j.jenkins.getRootDir(), "f2");
                new FileOutputStream(f1).close();
                p.setDefinition(new CpsFlowDefinition(
                    "node('dumbo') {\n" +
                    "    sh 'touch \"" + f2 + "\"; while [ -f \"" + f1 + "\" ]; do sleep 1; done; echo finished waiting; rm \"" + f2 + "\"'\n" +
                    "    echo 'OK, done'\n" +
                    "}"));
                startBuilding();
View Full Code Here

        p = r.jenkins.createProject(WorkflowJob.class, "p");
        r.jenkins.getInjector().injectMembers(this);
    }

    @Test public void basics() throws Exception {
        p.setDefinition(new CpsFlowDefinition("println('hello')"));
        WorkflowRun b1 = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
        assertFalse(b1.isBuilding());
        // TODO protected (but !building -> !inProgress): assertFalse(b1.isInProgress());
        assertFalse(b1.isLogUpdated());
        WorkflowRun b2 = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
View Full Code Here

        assertEquals(b1, b2.getPreviousBuild());
        assertEquals(null, b1.getPreviousBuild());
    }

    @Test public void parameters() throws Exception {
        p.setDefinition(new CpsFlowDefinition("node {sh('echo param=' + PARAM)}"));
        p.addProperty(new ParametersDefinitionProperty(new StringParameterDefinition("PARAM", null)));
        WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0, new ParametersAction(new StringParameterValue("PARAM", "value"))));
        r.assertLogContains("param=value", b);
    }
View Full Code Here

    public void iconColor() throws Exception {
        // marker file I use for synchronization
        FilePath test = new FilePath(r.jenkins.root).child("touch");


        p.setDefinition(new CpsFlowDefinition(
            "println('hello')\n"+
            "watch(new File('"+test.getRemote()+"'))\n"+
            "println('hello')\n"
        ));
View Full Code Here

        }
        r.jenkins.setAuthorizationStrategy(gmas);
        final String groovy = "println 'hello'";
        ACL.impersonate(User.get("devel").impersonate(), new Runnable() {
            @Override public void run() {
                p.setDefinition(new CpsFlowDefinition(groovy));
            }
        });
        r.assertLogContains("UnapprovedUsageException", r.assertBuildStatus(Result.FAILURE, p.scheduleBuild2(0).get()));
        Set<ScriptApproval.PendingScript> pendingScripts = ScriptApproval.get().getPendingScripts();
        assertEquals(1, pendingScripts.size());
View Full Code Here

    }

    @Test @Issue("JENKINS-25630")
    public void contextInjectionOfSubParameters() throws Exception {
        // see SubtypeInjectingStep
        p.setDefinition(new CpsFlowDefinition("node('master') { injectSubtypesAsContext() }"));
        r.assertBuildStatusSuccess(p.scheduleBuild2(0));
    }
View Full Code Here

    public void stepExecutionFailsToPersist() throws Exception {
        story.addStep(new Statement() {
            @Override
            public void evaluate() throws Throwable {
                p = jenkins().createProject(WorkflowJob.class, "demo");
                p.setDefinition(new CpsFlowDefinition(join(
                        "node {",
                        "  persistenceProblem()",
                        "}"
                )));
View Full Code Here

TOP

Related Classes of org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition

Copyright © 2018 www.massapicom. 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.