Search in sources :

Example 1 with HtmlPublisherTarget

use of htmlpublisher.HtmlPublisherTarget in project htmlpublisher-plugin by jenkinsci.

the class PublishHTMLStepTest method testDeprecationWarningNotDisplayedWhenNotTryingToResolveParameters.

@Test
public void testDeprecationWarningNotDisplayedWhenNotTryingToResolveParameters() throws Exception {
    writeTestHTML("index.html");
    final HtmlPublisherTarget target = new HtmlPublisherTarget("testReport", TEST_REPORT_DIR, "test", false, false, false);
    setupAndRunProject(target);
    // Ensure that the report has been attached properly
    r.assertBuildStatus(Result.SUCCESS, run);
    r.assertLogNotContains("*** WARNING ***", run);
}
Also used : HtmlPublisherTarget(htmlpublisher.HtmlPublisherTarget) Test(org.junit.Test)

Example 2 with HtmlPublisherTarget

use of htmlpublisher.HtmlPublisherTarget in project htmlpublisher-plugin by jenkinsci.

the class PublishHTMLStepTest method publishMissingReport_allowMissing.

@Test
public void publishMissingReport_allowMissing() throws Exception {
    final HtmlPublisherTarget target = new HtmlPublisherTarget("testReport", "testReportDirNonExistent", "index.html", false, false, true);
    target.setReportTitles("index");
    setupAndRunProject(target);
    // Ensure that the report has been attached
    r.assertBuildStatus(Result.SUCCESS, run);
    HtmlPublisherTarget.HTMLBuildAction report = run.getAction(HtmlPublisherTarget.HTMLBuildAction.class);
    assertNull("Report should be missing", report);
}
Also used : HtmlPublisherTarget(htmlpublisher.HtmlPublisherTarget) Test(org.junit.Test)

Example 3 with HtmlPublisherTarget

use of htmlpublisher.HtmlPublisherTarget in project htmlpublisher-plugin by jenkinsci.

the class PublishHTMLStepTest method configRoundTrip.

private void configRoundTrip(String reportName, String reportDir, String reportFiles, boolean keepAll, boolean alwaysLinkToLastBuild, boolean allowMissing) throws Exception {
    final HtmlPublisherTarget target = new HtmlPublisherTarget(reportName, reportDir, reportFiles, false, false, false);
    target.setReportTitles("index");
    configRoundTrip(target);
}
Also used : HtmlPublisherTarget(htmlpublisher.HtmlPublisherTarget)

Example 4 with HtmlPublisherTarget

use of htmlpublisher.HtmlPublisherTarget in project htmlpublisher-plugin by jenkinsci.

the class PublishHTMLStepTest method publishMissingReportFolder.

@Test
public void publishMissingReportFolder() throws Exception {
    final String missingReportDir = "testReportDirNonExistent";
    final HtmlPublisherTarget target = new HtmlPublisherTarget("testReport", missingReportDir, "index.html", false, false, false);
    target.setReportTitles("index");
    setupAndRunProject(target);
    File missingReportDirFile = new File(testWorkspace, "workspace/" + TEST_PROJECT_NAME + "/" + missingReportDir);
    // Ensure that the report has been attached
    r.assertBuildStatus(Result.FAILURE, run);
    HtmlPublisherTarget.HTMLBuildAction report = run.getAction(HtmlPublisherTarget.HTMLBuildAction.class);
    assertNull("Report should be missing", report);
    r.assertLogContains("Specified HTML directory '" + missingReportDirFile + "' does not exist.", run);
}
Also used : HtmlPublisherTarget(htmlpublisher.HtmlPublisherTarget) File(java.io.File) Test(org.junit.Test)

Example 5 with HtmlPublisherTarget

use of htmlpublisher.HtmlPublisherTarget in project htmlpublisher-plugin by jenkinsci.

the class PublishHTMLStepExecution method run.

@Override
protected Void run() throws Exception {
    final HtmlPublisherTarget target = step.getTarget();
    if (target == null) {
        throw new AbortException("Cannot publish the report. Target is not specified");
    }
    boolean res = HtmlPublisher.publishReports(getContext().get(Run.class), getContext().get(FilePath.class), getContext().get(TaskListener.class), Collections.singletonList(target), HtmlPublisher.class);
    if (!res) {
        throw new AbortException("Cannot publish HTML files");
    }
    return null;
}
Also used : FilePath(hudson.FilePath) HtmlPublisherTarget(htmlpublisher.HtmlPublisherTarget) TaskListener(hudson.model.TaskListener) Run(hudson.model.Run) AbortException(hudson.AbortException)

Aggregations

HtmlPublisherTarget (htmlpublisher.HtmlPublisherTarget)9 Test (org.junit.Test)6 AbortException (hudson.AbortException)1 FilePath (hudson.FilePath)1 Run (hudson.model.Run)1 TaskListener (hudson.model.TaskListener)1 File (java.io.File)1