Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logstash-plugin preventing colored output from ansicolor #222

Closed
tszmytka opened this issue May 5, 2021 · 2 comments · Fixed by #225
Closed

logstash-plugin preventing colored output from ansicolor #222

tszmytka opened this issue May 5, 2021 · 2 comments · Fixed by #225
Assignees

Comments

@tszmytka
Copy link
Collaborator

tszmytka commented May 5, 2021

I have the same issue but i have found why we have the issue.

Jenkins: 2.263.4
AnsiColor: 0.7.5

To confirm our issue, while the job is running, the output is correct all the way up to completion. When we refresh the page or revisit it, the problem occurs. I have found a fixed (in our use case) and can replicate:

This pipeline job works fine including after refresh:

ansiColor('xterm') {
    node {
        stage('test') { // for display purposes
            sh 'printf "\\e[31mHello World\\e[0m\\n"'
            sh 'printf "Normal \\e[1mBold\\e[0m\\n"'
            sh 'printf "Normal \\e[4mUnderlined\\e[0m\\n"'
        }
    }
}

image
But we use the logstash plugin to output the logs to ES so the actual setup we use is this:

logstash {
    ansiColor('xterm') {
        node {
            stage('test') { // for display purposes
                sh 'printf "\\e[31mHello World\\e[0m\\n"'
                sh 'printf "Normal \\e[1mBold\\e[0m\\n"'
                sh 'printf "Normal \\e[4mUnderlined\\e[0m\\n"'
                
                sleep 5
            }
        }
    }
}

The output is fine during the run (had to put a sleep in to see the job showed correctly during the run) but after refreshing i get the issue:
image
If i switch around the logstash and ansi classes it works fine:

ansiColor('xterm') {
    logstash {
        node {
            stage('test') { // for display purposes
                sh 'printf "\\e[31mHello World\\e[0m\\n"'
                sh 'printf "Normal \\e[1mBold\\e[0m\\n"'
                sh 'printf "Normal \\e[4mUnderlined\\e[0m\\n"'
                
                sleep 5
            }
        }
    }
}

Originally posted by @thenom in #216 (comment)

@tszmytka tszmytka added the confirmed bug 🐛 Definitely an ansicolor plugin bug label May 5, 2021
@tszmytka
Copy link
Collaborator Author

tszmytka commented May 5, 2021

Similar to #193 and #201

tszmytka added a commit to tszmytka/ansicolor-plugin that referenced this issue May 13, 2021
@tszmytka tszmytka removed the confirmed bug 🐛 Definitely an ansicolor plugin bug label May 13, 2021
@tszmytka
Copy link
Collaborator Author

@thenom Thank you for identifying the issue.
As mentioned earlier - this is not really a bug in ansicolor-plugin but rather in logstash-plugin - if used around other steps it doesn't transfer metadata for some of the log lines which coloring functionality relies on.
Nevertheless I've prepared a workaround that forces correct behavior at a small cost of 2 additional empty lines in the log output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant