Package hudson.matrix

Examples of hudson.matrix.MatrixProject$DescriptorImpl


        if (project instanceof MatrixConfiguration) {
            MatrixConfiguration matrixConfiguration = (MatrixConfiguration) project;
            subst.putAll(matrixConfiguration.getCombination());
        }
        if (project instanceof MatrixProject) {
            MatrixProject matrixProject = (MatrixProject) project;
            for (Axis axis : matrixProject.getAxes()) {
                subst.put(axis.name, axis.size() >0 ? axis.value(0) : "");
            }
        }
    }
View Full Code Here


    }
   
    public void testMatrixBuildsOnSameNodes() throws Exception {
        // all builds runs on master.
        // upstream matrix projects creates properties files in each builds.
        MatrixProject upstream = createMatrixProject();
        upstream.setAxes(new AxisList(new TextAxis("childname", "child1", "child2")));
        WriteFileBuilder wfb = new WriteFileBuilder("properties.txt", "triggered_${childname}=true");
       
        FreeStyleProject downstream = createFreeStyleProject();
       
        // Without useMatrixBuild, publisher
        // Downstream project is triggered without parameters.
        {
            upstream.getBuildersList().clear();
            upstream.getBuildersList().add(wfb);
           
            upstream.getPublishersList().clear();
            upstream.getPublishersList().add(new BuildTrigger(
                    new BuildTriggerConfig(downstream.getFullName(), ResultCondition.SUCCESS, true, Arrays.<AbstractBuildParameters>asList(
                            new FileBuildParameters("properties.txt", null, false, false, null, false)
                    ))
            ));
           
            jenkins.rebuildDependencyGraph();
           
            assertEquals(0, downstream.getBuilds().size());
           
            upstream.scheduleBuild2(0).get();
            waitUntilNoActivity();
           
            assertEquals(1, downstream.getBuilds().size());
            FreeStyleBuild build = downstream.getLastBuild();
            assertNull(getStringParameterValue(build, "triggered_child1"));
            assertNull(getStringParameterValue(build, "triggered_child2"));
            build.delete();
        }
       
        // With useMatrixBuild, publisher
        // Downstream project is triggered with parameters, merging properties files in all children.
        {
            upstream.getBuildersList().clear();
            upstream.getBuildersList().add(wfb);
           
            upstream.getPublishersList().clear();
            upstream.getPublishersList().add(new BuildTrigger(
                    new BuildTriggerConfig(downstream.getFullName(), ResultCondition.SUCCESS, true, Arrays.<AbstractBuildParameters>asList(
                            new FileBuildParameters("properties.txt", null, false, true, null, false)
                    ))
            ));
           
            jenkins.rebuildDependencyGraph();
           
            assertEquals(0, downstream.getBuilds().size());
           
            upstream.scheduleBuild2(0).get();
            waitUntilNoActivity();
           
            // Build is triggered without parameters.
            assertEquals(1, downstream.getBuilds().size());
            FreeStyleBuild build = downstream.getLastBuild();
            assertEquals("true", getStringParameterValue(build, "triggered_child1"));
            assertEquals("true", getStringParameterValue(build, "triggered_child2"));
            build.delete();
        }
       
        // Without useMatrixBuild, builder
        // Downstream project is triggered with parameters of each child.
        {
            upstream.getBuildersList().clear();
            upstream.getBuildersList().add(wfb);
            upstream.getBuildersList().add(new TriggerBuilder(
                    new BlockableBuildTriggerConfig(downstream.getFullName(), null, Arrays.<AbstractBuildParameters>asList(
                            new FileBuildParameters("properties.txt", null, false, false, null, false)
                    ))
            ));
           
            upstream.getPublishersList().clear();
           
            jenkins.rebuildDependencyGraph();
           
            assertEquals(0, downstream.getBuilds().size());
           
            upstream.scheduleBuild2(0).get();
            waitUntilNoActivity();
           
            // Build is triggered in each builds with parameters.
            assertEquals(2, downstream.getBuilds().size());
            FreeStyleBuild build1 = downstream.getLastBuild();
            FreeStyleBuild build2 = build1.getPreviousBuild();
           
            if (build1.getCause(Cause.UpstreamCause.class).getUpstreamProject().contains("child1")) {
                assertEquals("true", getStringParameterValue(build1, "triggered_child1"));
                assertNull(getStringParameterValue(build1, "triggered_child2"));
               
                assertNull(getStringParameterValue(build2, "triggered_child1"));
                assertEquals("true", getStringParameterValue(build2, "triggered_child2"));
            } else {
                assertEquals("true", getStringParameterValue(build2, "triggered_child1"));
                assertNull(getStringParameterValue(build2, "triggered_child2"));
               
                assertNull(getStringParameterValue(build1, "triggered_child1"));
                assertEquals("true", getStringParameterValue(build1, "triggered_child2"));
            }
           
            build2.delete();
            build1.delete();
        }
       
        // With useMatrixBuild, publisher
        // Downstream project is triggered with parameters of each child.
        // (useMatrixBuild is ignored)
        {
            upstream.getBuildersList().clear();
            upstream.getBuildersList().add(wfb);
            upstream.getBuildersList().add(new TriggerBuilder(
                    new BlockableBuildTriggerConfig(downstream.getFullName(), null, Arrays.<AbstractBuildParameters>asList(
                            new FileBuildParameters("properties.txt", null, false, true, null, false)
                    ))
            ));
           
            upstream.getPublishersList().clear();
           
            jenkins.rebuildDependencyGraph();
           
            assertEquals(0, downstream.getBuilds().size());
           
            upstream.scheduleBuild2(0).get();
            waitUntilNoActivity();
           
            // Build is triggered in each builds with parameters.
            assertEquals(2, downstream.getBuilds().size());
            FreeStyleBuild build1 = downstream.getLastBuild();
View Full Code Here

        // each builds run on other nodes.
        // upstream matrix projects creates properties files in each builds.
        createOnlineSlave(LabelExpression.parseExpression("child1"));
        createOnlineSlave(LabelExpression.parseExpression("child2"));
       
        MatrixProject upstream = createMatrixProject();
        upstream.setAxes(new AxisList(new LabelAxis("childname", Arrays.asList("child1", "child2"))));
        WriteFileBuilder wfb = new WriteFileBuilder("properties.txt", "triggered_${childname}=true");
       
        FreeStyleProject downstream = createFreeStyleProject();
       
        // Without useMatrixBuild, publisher
        // Downstream project is triggered without parameters.
        {
            upstream.getBuildersList().clear();
            upstream.getBuildersList().add(wfb);
           
            upstream.getPublishersList().clear();
            upstream.getPublishersList().add(new BuildTrigger(
                    new BuildTriggerConfig(downstream.getFullName(), ResultCondition.SUCCESS, true, Arrays.<AbstractBuildParameters>asList(
                            new FileBuildParameters("properties.txt", null, false, false, null, false)
                    ))
            ));
           
            jenkins.rebuildDependencyGraph();
           
            assertEquals(0, downstream.getBuilds().size());
           
            upstream.scheduleBuild2(0).get();
            waitUntilNoActivity();
           
            assertEquals(1, downstream.getBuilds().size());
            FreeStyleBuild build = downstream.getLastBuild();
            assertNull(getStringParameterValue(build, "triggered_child1"));
            assertNull(getStringParameterValue(build, "triggered_child2"));
            build.delete();
        }
       
        // With useMatrixBuild, publisher
        // Downstream project is triggered with parameters, merging properties files in all children.
        {
            upstream.getBuildersList().clear();
            upstream.getBuildersList().add(wfb);
           
            upstream.getPublishersList().clear();
            upstream.getPublishersList().add(new BuildTrigger(
                    new BuildTriggerConfig(downstream.getFullName(), ResultCondition.SUCCESS, true, Arrays.<AbstractBuildParameters>asList(
                            new FileBuildParameters("properties.txt", null, false, true, null, false)
                    ))
            ));
           
            jenkins.rebuildDependencyGraph();
           
            assertEquals(0, downstream.getBuilds().size());
           
            upstream.scheduleBuild2(0).get();
            waitUntilNoActivity();
           
            assertEquals(1, downstream.getBuilds().size());
            FreeStyleBuild build = downstream.getLastBuild();
            assertEquals("true", getStringParameterValue(build, "triggered_child1"));
            assertEquals("true", getStringParameterValue(build, "triggered_child2"));
            build.delete();
        }
       
        // Without useMatrixBuild, builder
        // Downstream project is triggered with parameters of each child.
        {
            upstream.getBuildersList().clear();
            upstream.getBuildersList().add(wfb);
            upstream.getBuildersList().add(new TriggerBuilder(
                    new BlockableBuildTriggerConfig(downstream.getFullName(), null, Arrays.<AbstractBuildParameters>asList(
                            new FileBuildParameters("properties.txt", null, false, false, null, false)
                    ))
            ));
           
            upstream.getPublishersList().clear();
           
            jenkins.rebuildDependencyGraph();
           
            assertEquals(0, downstream.getBuilds().size());
           
            upstream.scheduleBuild2(0).get();
            waitUntilNoActivity();
           
            assertEquals(2, downstream.getBuilds().size());
            FreeStyleBuild build1 = downstream.getLastBuild();
            FreeStyleBuild build2 = build1.getPreviousBuild();
           
            if (build1.getCause(Cause.UpstreamCause.class).getUpstreamProject().contains("child1")) {
                assertEquals("true", getStringParameterValue(build1, "triggered_child1"));
                assertNull(getStringParameterValue(build1, "triggered_child2"));
               
                assertNull(getStringParameterValue(build2, "triggered_child1"));
                assertEquals("true", getStringParameterValue(build2, "triggered_child2"));
            } else {
                assertEquals("true", getStringParameterValue(build2, "triggered_child1"));
                assertNull(getStringParameterValue(build2, "triggered_child2"));
               
                assertNull(getStringParameterValue(build1, "triggered_child1"));
                assertEquals("true", getStringParameterValue(build1, "triggered_child2"));
            }
           
            build2.delete();
            build1.delete();
        }
       
        // With useMatrixBuild, publisher
        // Downstream project is triggered with parameters of each child.
        // (useMatrixBuild is ignored)
        {
            upstream.getBuildersList().clear();
            upstream.getBuildersList().add(wfb);
            upstream.getBuildersList().add(new TriggerBuilder(
                    new BlockableBuildTriggerConfig(downstream.getFullName(), null, Arrays.<AbstractBuildParameters>asList(
                            new FileBuildParameters("properties.txt", null, false, true, null, false)
                    ))
            ));
           
            upstream.getPublishersList().clear();
           
            jenkins.rebuildDependencyGraph();
           
            assertEquals(0, downstream.getBuilds().size());
           
            upstream.scheduleBuild2(0).get();
            waitUntilNoActivity();
           
            assertEquals(2, downstream.getBuilds().size());
            FreeStyleBuild build1 = downstream.getLastBuild();
            FreeStyleBuild build2 = build1.getPreviousBuild();
View Full Code Here

            build1.delete();
        }
    }
   
    public void testMatrixBuildsCombinationFilter() throws Exception {
        MatrixProject upstream = createMatrixProject();
        upstream.setAxes(new AxisList(new TextAxis("childname", "child1", "child2", "child3")));
        upstream.getBuildersList().add(new WriteFileBuilder("properties.txt", "triggered_${childname}=true"));
       
        FreeStyleProject downstream = createFreeStyleProject();
       
        // without combinationFilter
        {
            upstream.getPublishersList().clear();
            upstream.getPublishersList().add(new BuildTrigger(
                    new BuildTriggerConfig(downstream.getFullName(), ResultCondition.SUCCESS, true, Arrays.<AbstractBuildParameters>asList(
                            new FileBuildParameters("properties.txt", null, false, true, null, false)
                    ))
            ));
           
            jenkins.rebuildDependencyGraph();
           
            assertEquals(0, downstream.getBuilds().size());
           
            upstream.scheduleBuild2(0).get();
            waitUntilNoActivity();
           
            assertEquals(1, downstream.getBuilds().size());
            FreeStyleBuild build = downstream.getLastBuild();
            assertEquals("true", getStringParameterValue(build, "triggered_child1"));
            assertEquals("true", getStringParameterValue(build, "triggered_child2"));
            assertEquals("true", getStringParameterValue(build, "triggered_child3"));
            build.delete();
        }
       
        // with combinationFilter
        {
            upstream.getPublishersList().clear();
            upstream.getPublishersList().add(new BuildTrigger(
                    new BuildTriggerConfig(downstream.getFullName(), ResultCondition.SUCCESS, true, Arrays.<AbstractBuildParameters>asList(
                            new FileBuildParameters("properties.txt", null, false, true, "childname!='child2'", false)
                    ))
            ));
           
            jenkins.rebuildDependencyGraph();
           
            assertEquals(0, downstream.getBuilds().size());
           
            upstream.scheduleBuild2(0).get();
            waitUntilNoActivity();
           
            assertEquals(1, downstream.getBuilds().size());
            FreeStyleBuild build = downstream.getLastBuild();
            assertEquals("true", getStringParameterValue(build, "triggered_child1"));
View Full Code Here

            build.delete();
        }
    }
   
    public void testMatrixBuildsOnlyExactRuns() throws Exception {
        MatrixProject upstream = createMatrixProject();
        upstream.setAxes(new AxisList(new TextAxis("childname", "child1", "child2", "child3")));
        upstream.getBuildersList().add(new WriteFileBuilder("properties.txt", "triggered_${childname}=true"));
       
        FreeStyleProject downstream = createFreeStyleProject();
       
        // Run build.
        // builds of child1, child2, child3 is created.
        upstream.scheduleBuild2(0).get();
       
        // child2 is dropped
        upstream.setAxes(new AxisList(new TextAxis("childname", "child1", "child3")));
       
        // without onlyExactRuns
        {
            upstream.getPublishersList().clear();
            upstream.getPublishersList().add(new BuildTrigger(
                    new BuildTriggerConfig(downstream.getFullName(), ResultCondition.SUCCESS, true, Arrays.<AbstractBuildParameters>asList(
                            new FileBuildParameters("properties.txt", null, false, true, null, false)
                    ))
            ));
           
            jenkins.rebuildDependencyGraph();
           
            assertEquals(0, downstream.getBuilds().size());
           
            upstream.scheduleBuild2(0).get();
            waitUntilNoActivity();
           
            assertEquals(1, downstream.getBuilds().size());
            FreeStyleBuild build = downstream.getLastBuild();
            assertEquals("true", getStringParameterValue(build, "triggered_child1"));
            assertEquals("true", getStringParameterValue(build, "triggered_child2"));
            assertEquals("true", getStringParameterValue(build, "triggered_child3"));
            build.delete();
        }
       
        // with onlyExactRuns
        {
            upstream.getPublishersList().clear();
            upstream.getPublishersList().add(new BuildTrigger(
                    new BuildTriggerConfig(downstream.getFullName(), ResultCondition.SUCCESS, true, Arrays.<AbstractBuildParameters>asList(
                            new FileBuildParameters("properties.txt", null, false, true, null, true)
                    ))
            ));
           
            jenkins.rebuildDependencyGraph();
           
            assertEquals(0, downstream.getBuilds().size());
           
            upstream.scheduleBuild2(0).get();
            waitUntilNoActivity();
           
            assertEquals(1, downstream.getBuilds().size());
            FreeStyleBuild build = downstream.getLastBuild();
            assertEquals("true", getStringParameterValue(build, "triggered_child1"));
View Full Code Here

   
    @Bug(22705)
    public void testMatrixBuildsConfiguration() throws Exception {
        FreeStyleProject downstream = createFreeStyleProject();
       
        MatrixProject upstream = createMatrixProject();
        upstream.setAxes(new AxisList(new TextAxis("axis1", "value1", "value2")));
        upstream.getPublishersList().add(new BuildTrigger(
                new BuildTriggerConfig(downstream.getFullName(), ResultCondition.SUCCESS, true, Arrays.<AbstractBuildParameters>asList(
                        new FileBuildParameters("properties.txt", "UTF-8", true, true, "axis1=value1", true)
                ))
        ));
        upstream.save();
       
        String upstreamName = upstream.getFullName();
       
        WebClient wc = createWebClient();
        submit(wc.getPage(upstream, "configure").getFormByName("config"));
       
        upstream = jenkins.getItemByFullName(upstreamName, MatrixProject.class);
        assertNotNull(upstream);
       
        BuildTrigger trigger = upstream.getPublishersList().get(BuildTrigger.class);
        assertNotNull(trigger);
       
        assertEquals(1, trigger.getConfigs().size());
       
        BuildTriggerConfig config = trigger.getConfigs().get(0);
View Full Code Here

        createFreeStyleProject("project3");
        createFreeStyleProject("project4");
        createFreeStyleProject("project5");
        createFreeStyleProject("project6");

        MatrixProject matrixProject = createMatrixProject("matrixProject");

        TriggerBuilder triggerBuilder = new TriggerBuilder(createTriggerConfig("project1"));
        triggerBuilder.getConfigs().add(createTriggerConfig("project2"));
        triggerBuilder.getConfigs().add(createTriggerConfig("project3"));
        triggerBuilder.getConfigs().add(createTriggerConfig("project4"));
        triggerBuilder.getConfigs().add(createTriggerConfig("project5"));
        triggerBuilder.getConfigs().add(createTriggerConfig("project6"));

        matrixProject.getBuildersList().add(triggerBuilder);

        matrixProject.scheduleBuild2(0).get();

        List<String> log2 = matrixProject.getLastBuild().getLog(20);
        System.out.println(log2);

        List<MatrixRun> runs = matrixProject.getLastBuild().getRuns();

        assertEquals(4,runs.size());

        for (MatrixRun run : runs) {
            assertLinesRegex(run,
View Full Code Here

        assertEquals("UpstreamCause is not properly set.", project1.getName(), c.getUpstreamProject());
    }

    @Override
    protected MatrixProject createMatrixProject(String name) throws IOException {
        MatrixProject p = super.createMatrixProject(name);
        // set up 2x2 matrix
        AxisList axes = new AxisList();
        axes.add(new TextAxis("db","mysql","oracle"));
        axes.add(new TextAxis("direction","north","south"));
        p.setAxes(axes);

        return p;
    }
View Full Code Here

        User user = createMock(User.class);
        expect(user.getId()).andReturn(USER).times(2);
        mockStatic(User.class);
        expect(User.current()).andReturn(user);
        replayAll();
        MatrixProject matrixProjectProject = new MatrixProject("matrixProject");
        FreeStyleProject freeStyleProject = new FreeStyleProjectMock("testJob");
        freeStyleProject.onCopiedFrom(matrixProjectProject);
        verifyAll();
        assertEquals(freeStyleProject.getNextBuildNumber(), 1);
        assertTrue(freeStyleProject.isHoldOffBuildUntilSave());
View Full Code Here

        User user = createMock(User.class);
        expect(user.getId()).andReturn(USER).times(1);
        mockStatic(User.class);
        expect(User.current()).andReturn(user);
        replayAll();
        MatrixProject matrixProjectProject = new MatrixProject("matrixProject");
        FreeStyleProject freeStyleProject = new FreeStyleProjectMock("testJob");
        freeStyleProject.onCopiedFrom(matrixProjectProject);
        verifyAll();
        assertEquals(freeStyleProject.getNextBuildNumber(), 1);
        assertTrue(freeStyleProject.isHoldOffBuildUntilSave());
View Full Code Here

TOP

Related Classes of hudson.matrix.MatrixProject$DescriptorImpl

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.