Package hudson.model

Examples of hudson.model.FreeStyleProject


    @Test
    public void testAttachmentFromWorkspace() throws Exception {
        URL url = this.getClass().getResource("/test.pdf");
        final File attachment = new File(url.getFile());
       
        FreeStyleProject project = j.createFreeStyleProject("foo");
        ExtendedEmailPublisher publisher = new ExtendedEmailPublisher();
        publisher.attachmentsPattern = "*.pdf";
        publisher.recipientList = "mickey@disney.com";
       
        SuccessTrigger trigger = new SuccessTrigger(Collections.<RecipientProvider>singletonList(new ListRecipientProvider()), "", "", "", "", "", 0, "project");
       
        publisher.getConfiguredTriggers().add(trigger);
       
        project.getPublishersList().add(publisher);
       
        project.getBuildersList().add(new TestBuilder() {
            @Override
            public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
                build.getWorkspace().child("test.pdf").copyFrom(new FilePath(attachment));
                return true;
            }
        });
        FreeStyleBuild b = project.scheduleBuild2(0).get();    
        j.assertBuildStatusSuccess(b);
       
        Mailbox mbox = Mailbox.get("mickey@disney.com");
        assertEquals("Should have an email from success", 1, mbox.size());
       
View Full Code Here


    @Test
    public void testAttachmentFromWorkspaceSubdir() throws Exception {
        URL url = this.getClass().getResource("/test.pdf");
        final File attachment = new File(url.getFile());
       
        FreeStyleProject project = j.createFreeStyleProject("foo");
        ExtendedEmailPublisher publisher = new ExtendedEmailPublisher();
        publisher.attachmentsPattern = "**/*.pdf";
        publisher.recipientList = "mickey@disney.com";
       
        SuccessTrigger trigger = new SuccessTrigger(Collections.<RecipientProvider>singletonList(new ListRecipientProvider()), "", "", "", "", "", 0, "project");
       
        publisher.getConfiguredTriggers().add(trigger);
       
        project.getPublishersList().add(publisher);
       
        project.getBuildersList().add(new TestBuilder() {
            @Override
            public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
                build.getWorkspace().child("testreport").mkdirs();
                build.getWorkspace().child("testreport").child("test.pdf").copyFrom(new FilePath(attachment));
                return true;
            }
        });
        FreeStyleBuild b = project.scheduleBuild2(0).get();    
        j.assertBuildStatusSuccess(b);
       
        Mailbox mbox = Mailbox.get("mickey@disney.com");
        assertEquals("Should have an email from success", 1, mbox.size());
       
View Full Code Here

    public void testUpgadeToRecipientProvider() throws IOException {
        URL url = this.getClass().getResource("/recipient-provider-upgrade.xml");
        File jobConfig = new File(url.getFile());   

        final ExtendedEmailPublisherDescriptor desc = j.jenkins.getDescriptorByType(ExtendedEmailPublisherDescriptor.class);
        FreeStyleProject prj = j.createFreeStyleProject();
        prj.updateByXml((Source)new StreamSource(new FileReader(jobConfig)));
       
        ExtendedEmailPublisher pub = (ExtendedEmailPublisher)prj.getPublisher(desc);
       
        // make sure the publisher got picked up
        assertNotNull(pub);
       
        // make sure the trigger was marshalled
View Full Code Here

    @Rule
    public JenkinsRule j = new JenkinsRule();

    @Test
    public void testOnlyRegressionsAreShown() throws Exception {
        FreeStyleProject project = j.createFreeStyleProject("onlyRegressions");
        project.getPublishersList().add(new JUnitResultArchiver("target/testreports/*.xml", true, null));

        project.getBuildersList().add(new TestBuilder() {
            @Override
            public boolean perform(AbstractBuild<?, ?> abstractBuild, Launcher launcher, BuildListener buildListener) throws InterruptedException, IOException {
                final URL failedTestReport = OnlyRegressionsTest.class.getClassLoader().getResource("hudson/plugins/emailext/testreports/failed_test.xml");
                FilePath workspace = abstractBuild.getWorkspace();

                FilePath testDir = workspace.child("target").child("testreports");
                testDir.mkdirs();
                FilePath reportFile = testDir.child("failed_test.xml");
                reportFile.copyFrom(failedTestReport);

                return true;
            }
        });
        TaskListener listener = StreamTaskListener.fromStdout();
        project.scheduleBuild2(0).get();
        FailedTestsContent failedTestsContent = new FailedTestsContent();
        failedTestsContent.onlyRegressions = true;
        String content = failedTestsContent.evaluate(project.getLastBuild(), listener, FailedTestsContent.MACRO_NAME);
        assertTrue("The failing test should be reported the first time it fails", content.contains("hudson.plugins.emailext"));

        project.scheduleBuild2(0).get();
        content = failedTestsContent.evaluate(project.getLastBuild(), listener, FailedTestsContent.MACRO_NAME);
        assertFalse("The failing test should not be reported the second time it fails", content.contains("hudson.plugins.emailext"));
        assertTrue("The content should state that there are other failing tests still", content.contains("and 1 other failed test"));
    }
View Full Code Here

   
    @Bug(20524)
    @Test
    public void testMultipleTriggersOfSameType()
            throws Exception {
        FreeStyleProject prj = j.createFreeStyleProject("JENKINS-20524");
        prj.getPublishersList().add(publisher);
       
        publisher.recipientList = "mickey@disney.com";
        publisher.configuredTriggers.add(new SuccessTrigger(recProviders, "$DEFAULT_RECIPIENTS",
                "$DEFAULT_REPLYTO", "$DEFAULT_SUBJECT", "$DEFAULT_CONTENT", "", 0, "project"));
        publisher.configuredTriggers.add(new SuccessTrigger(recProviders, "$DEFAULT_RECIPIENTS",
                "$DEFAULT_REPLYTO", "$DEFAULT_SUBJECT", "$DEFAULT_CONTENT", "", 0, "project"));
       
        for(EmailTrigger trigger : publisher.configuredTriggers) {
            trigger.getEmail().addRecipientProvider(new ListRecipientProvider());
        }
       
        FreeStyleBuild build = prj.scheduleBuild2(0).get();
        j.assertBuildStatusSuccess(build);

        assertEquals(2, Mailbox.get("mickey@disney.com").size());       
    }
View Full Code Here

    }
   
    @Bug(22154)
    @Test
    public void testProjectDisable() throws Exception {
        FreeStyleProject prj = j.createFreeStyleProject("JENKINS-22154");
        prj.getPublishersList().add(publisher);
       
        publisher.disabled = true;
        publisher.recipientList = "mickey@disney.com";
        publisher.configuredTriggers.add(new SuccessTrigger(recProviders, "$DEFAULT_RECIPIENTS",
                "$DEFAULT_REPLYTO", "$DEFAULT_SUBJECT", "$DEFAULT_CONTENT", "", 0, "project"));
       
        for(EmailTrigger trigger : publisher.configuredTriggers) {
            trigger.getEmail().addRecipientProvider(new ListRecipientProvider());
        }
       
        FreeStyleBuild build = prj.scheduleBuild2(0).get();
        j.assertBuildStatusSuccess(build);
       
        assertEquals(0, Mailbox.get("mickey@disney.com").size());       
        assertThat("Publisher is disabled, should have message in build log", build.getLog(100),
                hasItem("Extended Email Publisher is currently disabled in project settings"));       
View Full Code Here

    @Rule
    public JenkinsRule j = new JenkinsRule();

    @Test
    public void test1() throws Exception {
        FreeStyleProject project = j.createFreeStyleProject();
        TaskListener listener = StreamTaskListener.fromStdout();
        project.getBuildersList().add(new TestBuilder() {
            @Override
            public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
                build.getWorkspace().child("foo").write("Hello, world!", "UTF-8");
                return true;
            }
        });
        FreeStyleBuild build = project.scheduleBuild2(0).get();

        WorkspaceFileContent content = new WorkspaceFileContent();
        content.path = "foo";
        assertEquals("Hello, world!", content.evaluate(build, listener, WorkspaceFileContent.MACRO_NAME));
        content.path = "no-such-file";
View Full Code Here

        hudson.setNumExecutors(0);
    }

    public void testTakeBlockedByProperty() throws Exception {
        Slave slave = createSlave();
        FreeStyleProject project = createFreeStyleProject();

        // First, attempt to run our project before adding the property
        Future<FreeStyleBuild> build = project.scheduleBuild2(0);
        assertBuildStatus(Result.SUCCESS, build.get(20, TimeUnit.SECONDS));

        // Add the build-blocker property and try again
        slave.getNodeProperties().add(new RejectAllTasksProperty());

        build = project.scheduleBuild2(0);
        try {
            build.get(10, TimeUnit.SECONDS);
            fail("Expected timeout exception");
        } catch (TimeoutException e) {
            List<BuildableItem> buildables = hudson.getQueue().getBuildableItems();
View Full Code Here

    /**
     * Makes sure that {@link AlternativeUiTextProvider} actually works at some basic level.
     */
    public void testBasics() throws Exception {
        FreeStyleProject p = createFreeStyleProject("aaa");
        assertTrue(createWebClient().getPage(p).asText().contains("XYZ:aaa"));
    }
View Full Code Here

public class ProcessTreeKillerTest extends HudsonTestCase {

  public void testManualAbortProcess() throws Exception {
    ProcessTree.enabled = true;
    FreeStyleProject project = createFreeStyleProject();
   
    // this contains a maven project with a single test that sleeps 5s.
    project.setScm(new ExtractResourceSCM(getClass().getResource(
        "ProcessTreeKiller-test-project.jar")));
    project.getBuildersList().add(new Maven("install", "maven"));

    // build the project, wait until tests are running, then cancel.
    project.scheduleBuild(0);
    Thread.sleep(2000);

        FreeStyleBuild b = project.getLastBuild();
        b.doStop(
        EasyMock.createNiceMock(StaplerRequest.class),
        EasyMock.createNiceMock(StaplerResponse.class));

    Thread.sleep(1000);
View Full Code Here

TOP

Related Classes of hudson.model.FreeStyleProject

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.