From 11402e7d01fa9915d143963f8d8deacaa9103226 Mon Sep 17 00:00:00 2001 From: The-Jonsey Date: Thu, 11 Apr 2024 21:23:34 +0100 Subject: [PATCH 1/3] Add Icon Path Parameter --- .../htmlpublisher/HtmlPublisherTarget.java | 46 +++++++++++++++---- .../java/htmlpublisher/HtmlFileNameTest.java | 4 +- .../HtmlPublisherIntegrationTest.java | 34 +++++++------- .../java/htmlpublisher/HtmlPublisherTest.java | 5 +- .../java/htmlpublisher/Security3302Test.java | 5 +- 5 files changed, 62 insertions(+), 32 deletions(-) diff --git a/src/main/java/htmlpublisher/HtmlPublisherTarget.java b/src/main/java/htmlpublisher/HtmlPublisherTarget.java index 8460484..054934b 100644 --- a/src/main/java/htmlpublisher/HtmlPublisherTarget.java +++ b/src/main/java/htmlpublisher/HtmlPublisherTarget.java @@ -75,6 +75,12 @@ public class HtmlPublisherTarget extends AbstractDescribableImpl build, Launcher launcher, return true; } }); - HtmlPublisherTarget target1 = new HtmlPublisherTarget("tab1", reportDir, "tab1.html", true, true, false); + HtmlPublisherTarget target1 = new HtmlPublisherTarget("tab1", reportDir, "tab1.html", true, true, false, ""); //default behavior is include all target1.setIncludes(HtmlPublisherTarget.INCLUDE_ALL_PATTERN); - HtmlPublisherTarget target2 = new HtmlPublisherTarget("tab2", reportDir, "tab2.html", true, true, false); + HtmlPublisherTarget target2 = new HtmlPublisherTarget("tab2", reportDir, "tab2.html", true, true, false, ""); String includes = "tab2.html"; target2.setIncludes(includes); assertEquals(includes, target2.getIncludes()); @@ -136,7 +136,7 @@ public boolean perform(AbstractBuild build, Launcher launcher, BuildListen return true; } }); - HtmlPublisherTarget target1 = new HtmlPublisherTarget("tab1", "", "tab1/test.txt,tab1/test2.txt,**/test3.txt", true, false, true); + HtmlPublisherTarget target1 = new HtmlPublisherTarget("tab1", "", "tab1/test.txt,tab1/test2.txt,**/test3.txt", true, false, true, ""); p.getPublishersList().add(new HtmlPublisher(Arrays.asList(target1))); p.setAssignedLabel(Label.get("agent")); FreeStyleBuild build = j.buildAndAssertSuccess(p); @@ -168,7 +168,7 @@ public boolean perform(AbstractBuild build, Launcher launcher, return true; } }); - HtmlPublisherTarget target2 = new HtmlPublisherTarget("reportname", reportDir, "${MYREPORTFILES}", true, true, false ); + HtmlPublisherTarget target2 = new HtmlPublisherTarget("reportname", reportDir, "${MYREPORTFILES}", true, true, false, "" ); target2.setReportTitles("${MYREPORTTITLE}"); List targets = new ArrayList<>(); targets.add(target2); @@ -193,7 +193,7 @@ public boolean perform(AbstractBuild build, Launcher launcher, BuildListen return true; } }); - HtmlPublisherTarget target2 = new HtmlPublisherTarget("reportname", reportDir, "**/aReportDir/*/afile.html, **/otherDir/afile.html", true, true, false); + HtmlPublisherTarget target2 = new HtmlPublisherTarget("reportname", reportDir, "**/aReportDir/*/afile.html, **/otherDir/afile.html", true, true, false, ""); List targets = new ArrayList<>(); targets.add(target2); p.getPublishersList().add(new HtmlPublisher(targets)); @@ -216,8 +216,8 @@ public boolean perform(AbstractBuild build, Launcher launcher, BuildListen return true; } }); - HtmlPublisherTarget target1 = new HtmlPublisherTarget("reportnameB", "dirB", "", true, true, true); - HtmlPublisherTarget target2 = new HtmlPublisherTarget("reportnameA", "dirA", "", true, true, false); + HtmlPublisherTarget target1 = new HtmlPublisherTarget("reportnameB", "dirB", "", true, true, true, ""); + HtmlPublisherTarget target2 = new HtmlPublisherTarget("reportnameA", "dirA", "", true, true, false, ""); List targets = new ArrayList<>(); targets.add(target1); @@ -238,8 +238,8 @@ public boolean perform(AbstractBuild build, Launcher launcher, BuildListen return true; } }); - HtmlPublisherTarget target1 = new HtmlPublisherTarget("reportnameB", "dirB", "", true, true, false); - HtmlPublisherTarget target2 = new HtmlPublisherTarget("reportnameA", "dirA", "", true, true, false); + HtmlPublisherTarget target1 = new HtmlPublisherTarget("reportnameB", "dirB", "", true, true, false, ""); + HtmlPublisherTarget target2 = new HtmlPublisherTarget("reportnameA", "dirA", "", true, true, false, ""); List targets = new ArrayList<>(); targets.add(target1); @@ -266,11 +266,11 @@ public boolean perform(AbstractBuild build, Launcher launcher, }); - HtmlPublisherTarget target1 = new HtmlPublisherTarget("tab1", reportDir, "tab1.html", true, true, false); + HtmlPublisherTarget target1 = new HtmlPublisherTarget("tab1", reportDir, "tab1.html", true, true, false, ""); //default behavior is to not use wrapper file directly target1.setUseWrapperFileDirectly(false); assertFalse(target1.getUseWrapperFileDirectly()); - HtmlPublisherTarget target2 = new HtmlPublisherTarget("tab2", reportDir, "tab2.html", true, true, false); + HtmlPublisherTarget target2 = new HtmlPublisherTarget("tab2", reportDir, "tab2.html", true, true, false, ""); target2.setUseWrapperFileDirectly(true); assertTrue(target2.getUseWrapperFileDirectly()); @@ -296,8 +296,8 @@ public boolean perform(AbstractBuild build, Launcher launcher, BuildListen return true; } }); - HtmlPublisherTarget target1 = new HtmlPublisherTarget("reportnameB", "dirB", "", true, true, false); - HtmlPublisherTarget target2 = new HtmlPublisherTarget("reportnameA", "dirA", "", true, true, false); + HtmlPublisherTarget target1 = new HtmlPublisherTarget("reportnameB", "dirB", "", true, true, false, ""); + HtmlPublisherTarget target2 = new HtmlPublisherTarget("reportnameA", "dirA", "", true, true, false, ""); List targets = new ArrayList<>(); targets.add(target1); diff --git a/src/test/java/htmlpublisher/HtmlPublisherTest.java b/src/test/java/htmlpublisher/HtmlPublisherTest.java index 68edf48..6decfe7 100644 --- a/src/test/java/htmlpublisher/HtmlPublisherTest.java +++ b/src/test/java/htmlpublisher/HtmlPublisherTest.java @@ -7,7 +7,7 @@ public class HtmlPublisherTest { @Test public void testDefaultIncludes() { - HtmlPublisherTarget target1 = new HtmlPublisherTarget("tab1", "target", "tab1.html", true, true, false); + HtmlPublisherTarget target1 = new HtmlPublisherTarget("tab1", "target", "tab1.html", true, true, false, ""); assertEquals(HtmlPublisherTarget.INCLUDE_ALL_PATTERN, target1.getIncludes()); target1.setIncludes(null); assertEquals(HtmlPublisherTarget.INCLUDE_ALL_PATTERN, target1.getIncludes()); @@ -19,10 +19,11 @@ public void testDefaultIncludes() { @Test public void testSpacesTrimmed() { - HtmlPublisherTarget target = new HtmlPublisherTarget("tab1 ", "target ", "tab1.html ", true, true, false); + HtmlPublisherTarget target = new HtmlPublisherTarget("tab1 ", "target ", "tab1.html ", true, true, false, " icon.png "); assertEquals(target.getReportName(), "tab1"); assertEquals(target.getReportDir(), "target"); assertEquals(target.getReportFiles(), "tab1.html"); + assertEquals(target.getIconPath(), "icon.png"); } @Test diff --git a/src/test/java/htmlpublisher/Security3302Test.java b/src/test/java/htmlpublisher/Security3302Test.java index 738d5f1..2b84489 100644 --- a/src/test/java/htmlpublisher/Security3302Test.java +++ b/src/test/java/htmlpublisher/Security3302Test.java @@ -49,7 +49,7 @@ public void security3302sanitizeJobNameTest() throws Exception { target.setEscapeUnderscores(true); target.setReportTitles(""); target.setIncludes("**/*"); - + List reportTargets = new ArrayList<>(); reportTargets.add(target); @@ -125,7 +125,8 @@ public void security3302sanitizeOptionalNameTest() throws Exception { "test.txt", true, false, - false + false, + "" ); target.setUseWrapperFileDirectly(true); From 8d4f1b4d286539bc8b7d85b57c5cfc3c85cedf4a Mon Sep 17 00:00:00 2001 From: The-Jonsey Date: Thu, 11 Apr 2024 21:36:07 +0100 Subject: [PATCH 2/3] Fix tests --- .../workflow/PublishHTMLStepTest.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/test/java/htmlpublisher/workflow/PublishHTMLStepTest.java b/src/test/java/htmlpublisher/workflow/PublishHTMLStepTest.java index 22ff015..0df9467 100644 --- a/src/test/java/htmlpublisher/workflow/PublishHTMLStepTest.java +++ b/src/test/java/htmlpublisher/workflow/PublishHTMLStepTest.java @@ -91,7 +91,7 @@ public void configRoundTrip() throws Exception { public void testDeprecationWarningDisplayedWhenTryingToResolveParameters() throws Exception { writeTestHTML("index.html"); final HtmlPublisherTarget target = new HtmlPublisherTarget - ("testReport", TEST_REPORT_DIR, "${TEST}", false, false, false); + ("testReport", TEST_REPORT_DIR, "${TEST}", false, false, false, ""); setupAndRunProject(target); // Ensure that the report has been attached properly @@ -103,7 +103,7 @@ public void testDeprecationWarningDisplayedWhenTryingToResolveParameters() throw public void testDeprecationWarningNotDisplayedWhenNotTryingToResolveParameters() throws Exception { writeTestHTML("index.html"); final HtmlPublisherTarget target = new HtmlPublisherTarget - ("testReport", TEST_REPORT_DIR, "test", false, false, false); + ("testReport", TEST_REPORT_DIR, "test", false, false, false, ""); setupAndRunProject(target); // Ensure that the report has been attached properly @@ -119,7 +119,7 @@ public void publishReportOnProjectLevel() throws Exception { // Run the project final HtmlPublisherTarget target = new HtmlPublisherTarget - ("testReport", TEST_REPORT_DIR, "index.html", false, false, false); + ("testReport", TEST_REPORT_DIR, "index.html", false, false, false, ""); setupAndRunProject(target); // Ensure that the report has been attached properly @@ -139,7 +139,7 @@ public void publishReportOnBuildLevel() throws Exception { // Run the project final HtmlPublisherTarget target = new HtmlPublisherTarget - ("testReport", TEST_REPORT_DIR, "index.html", true, false, false); + ("testReport", TEST_REPORT_DIR, "index.html", true, false, false, ""); target.setReportTitles("index"); setupAndRunProject(target); @@ -157,7 +157,7 @@ public void publishReportOnBuildLevel() throws Exception { public void publishMissingReportFolder() throws Exception { final String missingReportDir = "testReportDirNonExistent"; final HtmlPublisherTarget target = new HtmlPublisherTarget - ("testReport", missingReportDir, "index.html", false, false, false); + ("testReport", missingReportDir, "index.html", false, false, false, ""); target.setReportTitles("index"); setupAndRunProject(target); File missingReportDirFile = new File(testWorkspace, "workspace/" + TEST_PROJECT_NAME + "/" + missingReportDir); @@ -172,7 +172,7 @@ public void publishMissingReportFolder() throws Exception { @Test public void publishMissingReport_allowMissing() throws Exception { final HtmlPublisherTarget target = new HtmlPublisherTarget - ("testReport", "testReportDirNonExistent", "index.html", false, false, true); + ("testReport", "testReportDirNonExistent", "index.html", false, false, true, ""); target.setReportTitles("index"); setupAndRunProject(target); @@ -214,7 +214,7 @@ private void setupAndRunProject(@NonNull HtmlPublisherTarget target) throws Exce private void configRoundTrip(String reportName, String reportDir, String reportFiles) throws Exception { final HtmlPublisherTarget target = new HtmlPublisherTarget - (reportName, reportDir, reportFiles, false, false, false); + (reportName, reportDir, reportFiles, false, false, false, ""); target.setReportTitles("index"); configRoundTrip(target); } @@ -222,7 +222,7 @@ private void configRoundTrip(String reportName, String reportDir, String reportF 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); + (reportName, reportDir, reportFiles, false, false, false, ""); target.setReportTitles("index"); configRoundTrip(target); } From 7d870f17cab3ce91913deb1f2e96aa7bf3847bd5 Mon Sep 17 00:00:00 2001 From: The-Jonsey Date: Thu, 11 Apr 2024 21:49:59 +0100 Subject: [PATCH 3/3] Fix Freestyle Job Configuration --- .../htmlpublisher/HtmlPublisherTarget/config.jelly | 3 +++ .../htmlpublisher/HtmlPublisherTarget/config.properties | 3 ++- .../htmlpublisher/HtmlPublisherTarget/help-iconPath.html | 3 +++ src/test/java/htmlpublisher/Security3302Test.java | 6 ++++-- 4 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 src/main/resources/htmlpublisher/HtmlPublisherTarget/help-iconPath.html diff --git a/src/main/resources/htmlpublisher/HtmlPublisherTarget/config.jelly b/src/main/resources/htmlpublisher/HtmlPublisherTarget/config.jelly index 2af293b..5890bf7 100644 --- a/src/main/resources/htmlpublisher/HtmlPublisherTarget/config.jelly +++ b/src/main/resources/htmlpublisher/HtmlPublisherTarget/config.jelly @@ -40,5 +40,8 @@ + + + \ No newline at end of file diff --git a/src/main/resources/htmlpublisher/HtmlPublisherTarget/config.properties b/src/main/resources/htmlpublisher/HtmlPublisherTarget/config.properties index 831f1dd..92346c7 100644 --- a/src/main/resources/htmlpublisher/HtmlPublisherTarget/config.properties +++ b/src/main/resources/htmlpublisher/HtmlPublisherTarget/config.properties @@ -8,4 +8,5 @@ keepAll.title=Keep past HTML reports alwaysLinkToLastBuild.title=Always link to last build allowMissing.title=Allow missing report escapeUnderscores.title=Escape underscores in Report Title -useWrapperFileDirectly.title=Use the legacy wrapper file \ No newline at end of file +useWrapperFileDirectly.title=Use the legacy wrapper file +iconPath.title=Sidebar Icon Path \ No newline at end of file diff --git a/src/main/resources/htmlpublisher/HtmlPublisherTarget/help-iconPath.html b/src/main/resources/htmlpublisher/HtmlPublisherTarget/help-iconPath.html new file mode 100644 index 0000000..6dad113 --- /dev/null +++ b/src/main/resources/htmlpublisher/HtmlPublisherTarget/help-iconPath.html @@ -0,0 +1,3 @@ +
+ The path of an icon to use for the HTML report in the sidebar (relative to reportDir) +
\ No newline at end of file diff --git a/src/test/java/htmlpublisher/Security3302Test.java b/src/test/java/htmlpublisher/Security3302Test.java index 2b84489..656082b 100644 --- a/src/test/java/htmlpublisher/Security3302Test.java +++ b/src/test/java/htmlpublisher/Security3302Test.java @@ -42,7 +42,8 @@ public void security3302sanitizeJobNameTest() throws Exception { "index.html", true, false, - false + false, + "" ); target.setUseWrapperFileDirectly(true); @@ -175,7 +176,8 @@ public void security3302sanitizeExistingReportTitleTest() throws Exception { "", true, false, - false + false, + "" ); target.setUseWrapperFileDirectly(true);