Package org.jenkinsci.plugins.workflow.job

Examples of org.jenkinsci.plugins.workflow.job.WorkflowJob


    @Test
    public void cancelBuildQueue() throws Exception {
        FreeStyleProject p = j.createFreeStyleProject("test1");
        p.getBuildersList().add(new Shell("sleep 6000"));

        WorkflowJob foo = j.jenkins.createProject(WorkflowJob.class, "foo");
        foo.setDefinition(new CpsFlowDefinition(StringUtils.join(Arrays.asList("build('test1');"), "\n")));

        j.jenkins.setNumExecutors(0); //should force freestyle build to remain in the queue?

        QueueTaskFuture<WorkflowRun> q = foo.scheduleBuild2(0);

        WorkflowRun b = q.getStartCondition().get();
        CpsFlowExecution e = (CpsFlowExecution) b.getExecutionPromise().get();
        e.waitForSuspension();
View Full Code Here


        j.assertBuildStatus(Result.FAILURE,q.get());
    }

    @SuppressWarnings("deprecation")
    @Test public void triggerWorkflow() throws Exception {
        WorkflowJob us = j.jenkins.createProject(WorkflowJob.class, "us");
        us.setDefinition(new CpsFlowDefinition("build 'ds'"));
        WorkflowJob ds = j.jenkins.createProject(WorkflowJob.class, "ds");
        ds.setDefinition(new CpsFlowDefinition("echo 'OK'"));
        j.assertBuildStatusSuccess(us.scheduleBuild2(0));
        assertEquals(1, ds.getBuilds().size());
    }
View Full Code Here

        j.assertBuildStatusSuccess(us.scheduleBuild2(0));
        assertEquals(1, ds.getBuilds().size());
    }

    @Test public void parameters() throws Exception {
        WorkflowJob us = j.jenkins.createProject(WorkflowJob.class, "us");
        FreeStyleProject ds = j.jenkins.createProject(FreeStyleProject.class, "ds");
        ds.addProperty(new ParametersDefinitionProperty(new StringParameterDefinition("branch", "master"), new BooleanParameterDefinition("extra", false, null)));
        ds.getBuildersList().add(new Shell("echo branch=$branch extra=$extra"));
        us.setDefinition(new CpsFlowDefinition("build 'ds'"));
        WorkflowRun us1 = j.assertBuildStatusSuccess(us.scheduleBuild2(0));
        FreeStyleBuild ds1 = ds.getBuildByNumber(1);
        j.assertLogContains("branch=master extra=false", ds1);
        Cause.UpstreamCause cause = ds1.getCause(Cause.UpstreamCause.class);
        assertNotNull(cause);
        assertEquals(us1, cause.getUpstreamRun());
        // TODO https://trello.com/c/d4gxlcQJ/78-parameterdefinition-create-object would be useful to let us bind a simple Groovy map
        us.setDefinition(new CpsFlowDefinition("build job: 'ds', parameters: [new hudson.model.StringParameterValue('branch', 'release')]"));
        j.assertBuildStatusSuccess(us.scheduleBuild2(0));
        // TODO IIRC there is an open PR regarding automatic filling in of default parameter values; should that be used, or is BuildTriggerStepExecution responsible, or ParameterizedJobMixIn.scheduleBuild2?
        j.assertLogContains("branch=release extra=", ds.getBuildByNumber(2));
        us.setDefinition(new CpsFlowDefinition("build job: 'ds', parameters: [new hudson.model.StringParameterValue('branch', 'release'), new hudson.model.BooleanParameterValue('extra', true)]"));
        j.assertBuildStatusSuccess(us.scheduleBuild2(0));
        j.assertLogContains("branch=release extra=true", ds.getBuildByNumber(3));
    }
View Full Code Here

TOP

Related Classes of org.jenkinsci.plugins.workflow.job.WorkflowJob

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.