Package hudson.model

Examples of hudson.model.Project


    Project<?,?> projectA = createFreeStyleProject("projectA");
    projectA.getPublishersList().add(
        new BuildTrigger(new BuildTriggerConfig("projectB", ResultCondition.SUCCESS, new CurrentBuildParameters())));

    CaptureEnvironmentBuilder builder = new CaptureEnvironmentBuilder();
    Project projectB = createFreeStyleProject("projectB");
    projectB.getBuildersList().add(builder);
    projectB.setQuietPeriod(1);
    hudson.rebuildDependencyGraph();

    projectA.scheduleBuild2(0, new UserCause(), new ParametersAction(
      new StringParameterValue("KEY", "value"))).get();
    hudson.getQueue().getItem(projectB).getFuture().get();

    assertNotNull("builder should record environment", builder.getEnvVars());
    assertEquals("value", builder.getEnvVars().get("KEY"));

                // Now rename projectB and confirm projectA's build trigger is updated automatically:
                projectB.renameTo("new-projectB");
                assertEquals("rename in trigger", "new-projectB", projectA.getPublishersList()
                             .get(BuildTrigger.class).getConfigs().get(0).getProjects());

                // Now delete projectB and confirm projectA's build trigger is updated automatically:
                projectB.delete();
                assertNull("now-empty trigger should be removed",
                           projectA.getPublishersList().get(BuildTrigger.class));
  }
View Full Code Here


        // trigger two dynamic project
        BlockableBuildTriggerConfig masterConfig = createConfig("sub${JOB_NAME}1, sub${JOB_NAME}2");
        addParameterizedTrigger(masterProject, masterConfig);

        // Only create 1 sub project
        Project subProject1 = createFreeStyleProject("subproject1");
        subProject1.setQuietPeriod(0);

        hudson.rebuildDependencyGraph();
        masterProject.scheduleBuild2(0, new Cause.UserCause()).get();

        // Expects 1 dynamic and 1 unresolved project
View Full Code Here

        // trigger two fixed project
        BlockableBuildTriggerConfig masterConfig = createConfig("subproject1, subproject2");
        addParameterizedTrigger(masterProject, masterConfig);

        // Only create 1 sub project
        Project subProject1 = createFreeStyleProject("subproject1");
        subProject1.setQuietPeriod(0);

        hudson.rebuildDependencyGraph();
        masterProject.scheduleBuild2(0, new Cause.UserCause()).get();

        // Expects 1 fixed and 1 unresolved project
View Full Code Here

    @Test
  public void testSingleFile() throws Exception {

        //create triggered build, with capture env builder
        Project projectB = createFreeStyleProject();
        CaptureAllEnvironmentBuilder builder = new CaptureAllEnvironmentBuilder();
        projectB.getBuildersList().add(builder);

        //create triggering build
        FreeStyleProject projectA = createFreeStyleProject();
        projectA.getBuildersList().add(new TestBuilder() {
            public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
            BuildListener listener) throws InterruptedException, IOException {
            build.getWorkspace().child("abc.txt").write("TEST=hello_abc","UTF-8");
            return true;
            }
        });

        // add Trigger builder, with file paramter factory
        projectA.getBuildersList().add(createTriggerBuilder(projectB, NoFilesFoundEnum.SKIP));

        projectA.scheduleBuild2(0).get();

        // check triggered builds are correct.
        waitUntilNoActivity();
        List<FreeStyleBuild> builds = projectB.getBuilds();
        assertEquals(1, builds.size());

        Set<String> values = Sets.newHashSet();
        for (FreeStyleBuild build : builds) {
            EnvVars buildEnvVar = builder.getEnvVars().get(build.getId());
View Full Code Here

    @Test
    public void testMultipleFiles() throws Exception {

        //create triggered build, with capture env builder
        Project projectB = createFreeStyleProject();
        CaptureAllEnvironmentBuilder builder = new CaptureAllEnvironmentBuilder();
        projectB.getBuildersList().add(builder);

        //create triggering build
        FreeStyleProject projectA = createFreeStyleProject();
        projectA.getBuildersList().add(new TestBuilder() {
            public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
            BuildListener listener) throws InterruptedException, IOException {
            build.getWorkspace().child("abc.txt").write("TEST=hello_abc","UTF-8");
            build.getWorkspace().child("xyz.txt").write("TEST=hello_xyz","UTF-8");
            build.getWorkspace().child("xyz.properties").write("TEST=hello_xyz","UTF-8");
            return true;
            }
        });

        // add Trigger builder, with file paramter factory
        projectA.getBuildersList().add(createTriggerBuilder(projectB, NoFilesFoundEnum.SKIP));

        projectA.scheduleBuild2(0).get();

        // check triggered builds are correct.
        waitUntilNoActivity();
        List<FreeStyleBuild> builds = projectB.getBuilds();
        assertEquals(2, builds.size());

        Set<String> values = Sets.newHashSet();
        for (FreeStyleBuild build : builds) {
            EnvVars buildEnvVar = builder.getEnvVars().get(build.getId());
View Full Code Here

    @Test
    public void testNoFilesSkip() throws Exception {

        //create triggered build, with capture env builder
        Project projectB = createFreeStyleProject();
        CaptureAllEnvironmentBuilder builder = new CaptureAllEnvironmentBuilder();
        projectB.getBuildersList().add(builder);

        //create triggering build
        FreeStyleProject projectA = createFreeStyleProject();

        // add Trigger builder, with file paramter factory
        projectA.getBuildersList().add(createTriggerBuilder(projectB, NoFilesFoundEnum.SKIP));

        projectA.scheduleBuild2(0).get();

        // check triggered builds are correct.
        waitUntilNoActivity();
        List<FreeStyleBuild> builds = projectB.getBuilds();
        assertEquals(0, builds.size());
    }
View Full Code Here

    @Test
    public void testNoFilesNoParms() throws Exception {

        //create triggered build, with capture env builder
        Project projectB = createFreeStyleProject();
        CaptureAllEnvironmentBuilder builder = new CaptureAllEnvironmentBuilder();
        projectB.getBuildersList().add(builder);

        //create triggering build
        FreeStyleProject projectA = createFreeStyleProject();

        // add Trigger builder, with file paramter factory
        projectA.getBuildersList().add(createTriggerBuilder(projectB, NoFilesFoundEnum.NOPARMS));

        projectA.scheduleBuild2(0).get();

        // check triggered builds are correct.
        waitUntilNoActivity();
        List<FreeStyleBuild> builds = projectB.getBuilds();
        assertEquals(1, builds.size());
    }
View Full Code Here

    @Test(expected = RuntimeException.class)
    public void testNoFilesFail() throws Exception {

        //create triggered build, with capture env builder
        Project projectB = createFreeStyleProject();
        CaptureAllEnvironmentBuilder builder = new CaptureAllEnvironmentBuilder();
        projectB.getBuildersList().add(builder);

        //create triggering build
        FreeStyleProject projectA = createFreeStyleProject();

        // add Trigger builder, with file paramter factory
        projectA.getBuildersList().add(createTriggerBuilder(projectB, NoFilesFoundEnum.FAIL));

        projectA.scheduleBuild2(0).get();

        // check triggered builds are correct.
        waitUntilNoActivity();
        List<FreeStyleBuild> builds = projectB.getBuilds();
        assertEquals(0, builds.size());
    }
View Full Code Here

    }

    public void testUtf8File() throws Exception {

        //create triggered build, with capture env builder
        Project projectB = createFreeStyleProject();
        CaptureAllEnvironmentBuilder builder = new CaptureAllEnvironmentBuilder();
        projectB.getBuildersList().add(builder);

        //create triggering build
        FreeStyleProject projectA = createFreeStyleProject();
        projectA.getBuildersList().add(new TestBuilder() {
            public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
            BuildListener listener) throws InterruptedException, IOException {
            build.getWorkspace().child("abc.txt").write(
                    "TEST=こんにちは\n"  // "hello" in Japanese.
                    + "TEST=hello_abc", // TEST in multibytes.
                    "UTF-8"
            );
            return true;
            }
        });

        // add Trigger builder, with file paramter factory
        projectA.getBuildersList().add(createTriggerBuilder(projectB, NoFilesFoundEnum.SKIP, "UTF-8"));

        projectA.scheduleBuild2(0).get();

        // check triggered builds are correct.
        waitUntilNoActivity();
        List<FreeStyleBuild> builds = projectB.getBuilds();
        assertEquals(1, builds.size());

        for (FreeStyleBuild build : builds) {
            EnvVars buildEnvVar = builder.getEnvVars().get(build.getId());
            System.out.println(String.format("'%s'", "こんにちは"));
View Full Code Here

    public void testShiftJISFile() throws Exception {
        // ShiftJIS is an encoding of Japanese texts.
        // I test here that a non-UTF-8 encoding also works.

        //create triggered build, with capture env builder
        Project projectB = createFreeStyleProject();
        CaptureAllEnvironmentBuilder builder = new CaptureAllEnvironmentBuilder();
        projectB.getBuildersList().add(builder);

        //create triggering build
        FreeStyleProject projectA = createFreeStyleProject();
        projectA.getBuildersList().add(new TestBuilder() {
            public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
            BuildListener listener) throws InterruptedException, IOException {
            build.getWorkspace().child("abc.txt").write(
                    "TEST=こんにちは\n"  // "hello" in Japanese.
                    + "TEST=hello_abc", // TEST in multibytes.
                    "Shift_JIS"
            );
            return true;
            }
        });

        // add Trigger builder, with file paramter factory
        projectA.getBuildersList().add(createTriggerBuilder(projectB, NoFilesFoundEnum.SKIP, "Shift_JIS"));

        projectA.scheduleBuild2(0).get();

        // check triggered builds are correct.
        waitUntilNoActivity();
        List<FreeStyleBuild> builds = projectB.getBuilds();
        assertEquals(1, builds.size());

        for (FreeStyleBuild build : builds) {
            EnvVars buildEnvVar = builder.getEnvVars().get(build.getId());
            assertEquals("こんにちは", buildEnvVar.get("TEST"));
View Full Code Here

TOP

Related Classes of hudson.model.Project

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.