Skip to content
Browse files

[JENKINS-42536] fix ansi console note (#62)

* [JENKINS-42536] fix ansi console note

When a line starts with a console note we trimmed the leading escape
character before passing it to the removeNotes method. This makes it not
recognize as a console note. So trim after removing the notes.
  • Loading branch information
mwinter69 authored and jakub-bochenski committed May 28, 2018
1 parent 3299837 commit 188ea2b05f0c7ed3398caf63012b075ae7bb177f
@@ -157,6 +157,12 @@

@@ -59,8 +59,8 @@ protected void eol(byte[] b, int len) throws IOException {

if(!logstash.isConnectionBroken()) {
String line = new String(b, 0, len, logstash.getCharset()).trim();
line = ConsoleNote.removeNotes(line);
String line = new String(b, 0, len, logstash.getCharset());
line = ConsoleNote.removeNotes(line).trim();

This comment has been minimized.

Copy link

akostadinov Jun 18, 2018

hmm, removing color data is IMO bad, reading bare colors log is a pain

This comment has been minimized.

Copy link
@@ -5,6 +5,7 @@
import static org.hamcrest.Matchers.equalTo;
import static;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.startsWith;
import static org.junit.Assert.assertThat;
import static org.powermock.api.mockito.PowerMockito.when;
import static org.mockito.ArgumentMatchers.any;
@@ -29,11 +30,13 @@
import com.michelin.cio.hudson.plugins.maskpasswords.MaskPasswordsConfig;
import com.michelin.cio.hudson.plugins.maskpasswords.MaskPasswordsBuildWrapper.VarPasswordPair;

import hudson.model.Cause;
import hudson.model.FreeStyleBuild;
import hudson.model.FreeStyleProject;
import hudson.model.Result;
import hudson.model.Slave;
import hudson.model.queue.QueueTaskFuture;
import hudson.plugins.ansicolor.AnsiColorBuildWrapper;
import net.sf.json.JSONArray;
import jenkins.plugins.logstash.persistence.MemoryDao;
import net.sf.json.JSONObject;
@@ -241,4 +244,20 @@ public void secondTimestamps() throws Exception

public void ansiColorAnnotationsAreNotIncluded() throws Exception
AnsiColorBuildWrapper ansi = new AnsiColorBuildWrapper("vga");
project.addProperty(new LogstashJobProperty());
Cause cause = new Cause.UserIdCause();
QueueTaskFuture<FreeStyleBuild> f = project.scheduleBuild2(0, cause);

FreeStyleBuild build = f.get();
assertThat(build.getResult(), equalTo(Result.SUCCESS));
List<JSONObject> dataLines = memoryDao.getOutput();
JSONObject firstLine = dataLines.get(0);

0 comments on commit 188ea2b

Please sign in to comment.