diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..fe8aa82 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,13 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +trim_trailing_whitespace = true +insert_final_newline = true +indent_style = space +indent_size = 4 +max_line_length = 200 + +[*.xml] +indent_size = 2 diff --git a/CHANGELOG.md b/CHANGELOG.md index 75e345d..30dca5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,10 @@ -0.7.0 (Next) +0.7.0 (05/23/2020) ============ * [#173](https://github.com/jenkinsci/ansicolor-plugin/pull/173): Fix for SGR Normal intensity not handled correctly - [@tszmytka](https://github.com/tszmytka). * [#176](https://github.com/jenkinsci/ansicolor-plugin/pull/176): Ensure extended color SGRs are recognized correctly - [@tszmytka](https://github.com/tszmytka). * [#156](https://github.com/jenkinsci/ansicolor-plugin/pull/156): Improve documentation - [@tszmytka](https://github.com/tszmytka). * [#181](https://github.com/jenkinsci/ansicolor-plugin/pull/181): Re-implement support for multiple ansiColor steps within one pipeline script - [@tszmytka](https://github.com/tszmytka). -* Your contribution here. 0.6.3 (02/24/2020) ============ diff --git a/RELEASING.md b/RELEASING.md index 22308ca..1bb630e 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -35,12 +35,16 @@ mvn test Check that the last build succeeded in [Travis CI](https://travis-ci.org/jenkinsci/ansicolor-plugin). -Ensure that the version in [pom.xml](pom.xml) is correct and ends with `-SNAPSHOT`. +Ensure that the version in [pom.xml](pom.xml) is correct and effectively ends with `-SNAPSHOT`. ``` xml ansicolor +${revision}${changelist} hpi -0.4.1-SNAPSHOT + + 0.7.0 + -SNAPSHOT + ``` Change "Next Release" in [CHANGELOG.md](CHANGELOG.md) to the new version. diff --git a/pom.xml b/pom.xml index 87203d9..cbd0a46 100644 --- a/pom.xml +++ b/pom.xml @@ -1,12 +1,13 @@ - + 4.0.0 org.jenkins-ci.plugins plugin - 4.1 - + 4.2 + ansicolor @@ -40,7 +41,7 @@ - 0.6.4 + 0.7.0 -SNAPSHOT 2.176.3 8 @@ -48,9 +49,9 @@ - org.jenkins-ci.plugins.workflow - workflow-step-api - true + org.jenkins-ci.plugins.workflow + workflow-step-api + true org.jenkins-ci.plugins.workflow diff --git a/src/test/java/hudson/plugins/ansicolor/AnsiColorBuildWrapperTest.java b/src/test/java/hudson/plugins/ansicolor/AnsiColorBuildWrapperTest.java index 9889687..a7bf771 100644 --- a/src/test/java/hudson/plugins/ansicolor/AnsiColorBuildWrapperTest.java +++ b/src/test/java/hudson/plugins/ansicolor/AnsiColorBuildWrapperTest.java @@ -27,8 +27,10 @@ import java.util.logging.Level; import java.util.stream.Collectors; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; public class AnsiColorBuildWrapperTest { private static final String ESC = "\033"; @@ -114,7 +116,7 @@ public boolean perform(AbstractBuild build, Launcher launcher, BuildListen }); FreeStyleBuild b = r.buildAndAssertSuccess(p); StringWriter writer = new StringWriter(); - b.getLogText().writeHtmlTo(0L, writer); + assertTrue(b.getLogText().writeHtmlTo(0L, writer) > 0); String html = writer.toString(); System.out.print(html); assertThat( @@ -143,7 +145,7 @@ public boolean perform(AbstractBuild build, Launcher launcher, BuildListen }); FreeStyleBuild b = r.buildAndAssertSuccess(p); StringWriter writer = new StringWriter(); - b.getLogText().writeHtmlTo(0L, writer); + assertTrue(b.getLogText().writeHtmlTo(0L, writer) > 0); String html = writer.toString(); System.out.print(html); String nl = System.lineSeparator(); @@ -175,7 +177,7 @@ public boolean perform(AbstractBuild build, Launcher launcher, BuildListen }); FreeStyleBuild b = r.buildAndAssertSuccess(p); StringWriter writer = new StringWriter(); - b.getLogText().writeHtmlTo(0L, writer); + assertTrue(b.getLogText().writeHtmlTo(0L, writer) > 0); String html = writer.toString(); System.out.print(html); String nl = System.lineSeparator(); @@ -210,10 +212,11 @@ public void evaluate() throws Throwable { + " )\n" + " }\n" + "}" + , false )); story.j.assertBuildStatusSuccess(p.scheduleBuild2(0)); StringWriter writer = new StringWriter(); - p.getLastBuild().getLogText().writeHtmlTo(0L, writer); + assertTrue(p.getLastBuild().getLogText().writeHtmlTo(0L, writer) > 0); String html = writer.toString(); assertTrue( "Failed to match color attribute in following HTML log output:\n" + html, @@ -240,7 +243,7 @@ public boolean perform(AbstractBuild build, Launcher launcher, BuildListen }); FreeStyleBuild b = r.buildAndAssertSuccess(p); StringWriter writer = new StringWriter(); - b.getLogText().writeHtmlTo(0L, writer); + assertTrue(b.getLogText().writeHtmlTo(0L, writer) > 0); String html = writer.toString(); assertThat( html.replaceAll("", ""), @@ -272,7 +275,7 @@ public boolean perform(AbstractBuild build, Launcher launcher, BuildListen }); FreeStyleBuild b = r.buildAndAssertSuccess(p); StringWriter writer = new StringWriter(); - b.getLogText().writeHtmlTo(0L, writer); + assertTrue(b.getLogText().writeHtmlTo(0L, writer) > 0); String html = writer.toString(); System.out.print(html); assertThat( @@ -301,7 +304,7 @@ public boolean perform(AbstractBuild build, Launcher launcher, BuildListen }); FreeStyleBuild b = r.buildAndAssertSuccess(p); StringWriter writer = new StringWriter(); - b.getLogText().writeHtmlTo(0L, writer); + assertTrue(b.getLogText().writeHtmlTo(0L, writer) > 0); String html = writer.toString(); System.out.print(html); assertThat( @@ -435,9 +438,7 @@ public void canRenderSgrFaintIntensity() { public void canHandleSgrsWithMultipleOptions() { final String input = "\u001B[33mbanana_1 |\u001B[0m 19:59:14.353\u001B[0;38m [debug] Lager installed handler {lager_file_backend,\"banana.log\"} into lager_event\u001B[0m\n"; - final Consumer inputProvider = stream -> { - stream.println(input); - }; + final Consumer inputProvider = stream -> stream.println(input); assertCorrectOutput( Collections.singletonList("banana_1 | 19:59:14.353 [debug] Lager installed handler {lager_file_backend,\"banana.log\"} into lager_event"), @@ -486,7 +487,7 @@ public boolean perform(AbstractBuild build, Launcher launcher, BuildListen }); final FreeStyleBuild b = rule.buildAndAssertSuccess(p); final StringWriter writer = new StringWriter(); - b.getLogText().writeHtmlTo(0L, writer); + assertTrue(b.getLogText().writeHtmlTo(0L, writer) > 0); return writer.toString(); } } diff --git a/src/test/java/hudson/plugins/ansicolor/AnsiColorStepTest.java b/src/test/java/hudson/plugins/ansicolor/AnsiColorStepTest.java index bfcbb7e..d4b68e7 100644 --- a/src/test/java/hudson/plugins/ansicolor/AnsiColorStepTest.java +++ b/src/test/java/hudson/plugins/ansicolor/AnsiColorStepTest.java @@ -60,7 +60,7 @@ public void evaluate() throws Throwable { , true)); WorkflowRun run = story.j.assertBuildStatusSuccess(p.scheduleBuild2(0)); StringWriter writer = new StringWriter(); - p.getLastBuild().getLogText().writeHtmlTo(0L, writer); + assertTrue(p.getLastBuild().getLogText().writeHtmlTo(0L, writer) > 0); String html = writer.toString(); story.j.assertLogContains("TERM=xterm", run); assertTrue( diff --git a/src/test/java/hudson/plugins/ansicolor/AnsiHtmlOutputStreamTest.java b/src/test/java/hudson/plugins/ansicolor/AnsiHtmlOutputStreamTest.java index 5662d91..e7aa6ae 100644 --- a/src/test/java/hudson/plugins/ansicolor/AnsiHtmlOutputStreamTest.java +++ b/src/test/java/hudson/plugins/ansicolor/AnsiHtmlOutputStreamTest.java @@ -23,15 +23,16 @@ */ package hudson.plugins.ansicolor; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; - import hudson.console.ConsoleNote; -import java.io.ByteArrayOutputStream; -import java.io.IOException; import org.junit.Test; import javax.annotation.Nonnull; +import java.io.ByteArrayOutputStream; +import java.io.IOException; + +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; public class AnsiHtmlOutputStreamTest { @@ -617,15 +618,15 @@ private String annotate(String text, AnsiColorMap colorMap) throws IOException { AnsiHtmlOutputStream ansi = new AnsiHtmlOutputStream(bos, colorMap, new AnsiAttributeElement.Emitter() { public void emitHtml(@Nonnull String html) { try { - bos.write(html.getBytes("UTF-8")); + bos.write(html.getBytes(UTF_8)); } catch (IOException e) { throw new RuntimeException("error emitting HTML", e); } } }); - ansi.write(text.getBytes("UTF-8")); + ansi.write(text.getBytes(UTF_8)); ansi.close(); - return bos.toString("UTF-8"); + return bos.toString(UTF_8.displayName()); } private String annotate(String text) throws IOException { diff --git a/src/test/java/hudson/plugins/ansicolor/ColorConsoleAnnotatorTest.java b/src/test/java/hudson/plugins/ansicolor/ColorConsoleAnnotatorTest.java index 1f6f040..6596e0e 100644 --- a/src/test/java/hudson/plugins/ansicolor/ColorConsoleAnnotatorTest.java +++ b/src/test/java/hudson/plugins/ansicolor/ColorConsoleAnnotatorTest.java @@ -1,15 +1,8 @@ package hudson.plugins.ansicolor; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import java.io.StringWriter; -import java.util.logging.Level; - +import jenkins.model.Jenkins; import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition; import org.jenkinsci.plugins.workflow.job.WorkflowJob; -import org.jenkinsci.plugins.workflow.job.WorkflowRun; import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; @@ -18,7 +11,11 @@ import org.jvnet.hudson.test.LoggerRule; import org.jvnet.hudson.test.RestartableJenkinsRule; -import jenkins.model.Jenkins; +import java.io.StringWriter; +import java.util.logging.Level; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; public class ColorConsoleAnnotatorTest { @@ -33,7 +30,7 @@ public ColorConsoleAnnotatorTest() { public LoggerRule logging = new LoggerRule().record(ColorConsoleAnnotator.class, Level.FINER); @Test - public void testGlobalPipelineColorMap() throws Exception { + public void testGlobalPipelineColorMap() { story.addStep(new Statement() { @Override public void evaluate() throws Throwable { @@ -42,9 +39,9 @@ public void evaluate() throws Throwable { p.setDefinition(new CpsFlowDefinition( "echo 'The following word is supposed to be \\u001B[31mred\\u001B[0m'" , true)); - WorkflowRun run = story.j.assertBuildStatusSuccess(p.scheduleBuild2(0)); + story.j.assertBuildStatusSuccess(p.scheduleBuild2(0)); StringWriter writer = new StringWriter(); - p.getLastBuild().getLogText().writeHtmlTo(0L, writer); + assertTrue(p.getLastBuild().getLogText().writeHtmlTo(0L, writer) > 0); String html = writer.toString(); assertTrue("Failed to match color attribute in following HTML log output:\n" + html, html.replaceAll("", "").matches("(?s).*red.*")); @@ -53,7 +50,7 @@ public void evaluate() throws Throwable { } @Test - public void testNoGlobalPipelineColorMap() throws Exception { + public void testNoGlobalPipelineColorMap() { story.addStep(new Statement() { @Override public void evaluate() throws Throwable { @@ -62,9 +59,9 @@ public void evaluate() throws Throwable { p.setDefinition(new CpsFlowDefinition( "echo 'The following word is supposed to be \\u001B[31mred\\u001B[0m'" , true)); - WorkflowRun run = story.j.assertBuildStatusSuccess(p.scheduleBuild2(0)); + story.j.assertBuildStatusSuccess(p.scheduleBuild2(0)); StringWriter writer = new StringWriter(); - p.getLastBuild().getLogText().writeHtmlTo(0L, writer); + assertTrue(p.getLastBuild().getLogText().writeHtmlTo(0L, writer) > 0); String html = writer.toString(); assertFalse("Color attribute was applied in following HTML log output even though the color map was not globally enabled:\n" + html, html.replaceAll("", "").matches("(?s).*red.*"));