Giter Club home page Giter Club logo

ansicolor-plugin's Introduction

Jenkins ANSI Color Plugin

Jenkins Build Status Jenkins Plugins Jenkins Plugin installs

This plugin adds support for standard ANSI escape sequences, including color, to Console Output.

This plugin is available here and has a page on the Jenkins Wiki.

Install

Using Plugin Manager

install

Using Jenkins CLI client

java -jar jenkins-cli.jar install-plugin ansicolor

Enable

In a Pipeline

There are 2 ways to explicitly enable ansicolor functionality in a pipeline: as a build wrapper - the cleanest and most preferable one or as a pipeline step - good for quick checks when you only need part of the output colored.

Build wrapper

Can be used to colorize the whole output of a pipeline build. Here is an example rendering a colorful message.

pipeline {
    agent any
    options {
        ansiColor('xterm')
    }
    stages {
        stage('Build') {
            steps {
                echo '\033[34mHello\033[0m \033[33mcolorful\033[0m \033[35mworld!\033[0m'
            }
        }
    }
}

Pipeline step

With the following syntax you can use the plugin without allocating a node or a separate build wrapper.

ansiColor('css') {
  sh "ls -al"
}

echo 'this will be rendered as-is'
// multiple ansiColor steps within one pipeline are also supported

ansiColor('vga') {
  echo '\033[42m\033[97mWhite letters, green background\033[0m'
}

The TERM environment variable will be set to the provided name inside the block scope.

ansiColor('xterm') {
  echo "TERM=${env.TERM}"
  // prints out TERM=xterm
}

Colormaps

The argument to the ansiColor function can be either xterm, vga, gnome-terminal or css. This defines which colors Jenkins should show for some of the escape codes. The exact color values used in each set are defined in AnsiColorMap.java.

In a traditional job

Traditional, Jenkins UI defined jobs, can also take advantage of ansicolor by enabling it under "Build Environment" settings.

enable

Example output:

color

Customize

color

In global settings

This option is the most suitable when you already have a large amount of jobs and you would like to enable ansicolor functionality for all of them in one go. In order to use it you need to specify Global color map for all builds on the Global configuration page available under:

Jenkins -> Manage Jenkins -> Configure System

Misc

Does it Even Work?

Create a job in Jenkins that executes the following shell script. Don't forget to check the "Color the ANSI Console Output" option.

printf "\e[31mHello World\e[0m\n"
printf "Normal \e[1mBold\e[0m\n"
printf "Normal \e[4mUnderlined\e[0m\n"

color

Check out this guide for more examples.

Notes on the shells Zsh and Bash

If you commonly use Zsh as your login shell, it's important to keep in mind that the echo command (shell builtin) supports character escaping.

Bash however, does not.

This can cause you a bit of confusion. For example, if you test your shell scripts (which use echo) in Zsh, and they work fine. Then you try to run them as part of a job on Jenkins (which will use be using Bash by default), it's quite possible you won't see colorized output, instead, you only see the ANSI control codes, still embedded in your text.

There are ways around this, however, we recommend you use the printf command instead. It'll just work everywhere, and allow \e, \033 or \x1b to be used as the escape character.

For example:

printf "\e[31mHello\e[0m\n"
printf "\033[31mHello\033[0m\n"
printf "\x1b[31mHello\x1b[0m\n"

Will all print Hello in red on any system / shell that has printf (ie. anything POSIX compliant)

Supported ANSI Color Codes and Attributes

Most of the attributes and color modes described at wikipedia/ANSI escape code were supported, including:

  • attributes bold / italic / underline / negative / conceal / crossed-out / framed / overlined
  • standard text colors 30-37 and background colors 40-47
  • high intensity text colors 90-97 and background colors 100-107 (aixterm)
  • xterm 256 colors and ISO-8613-3 24 bit colors (38 and 48)

Not supported attributes:

  • faint
  • blink
  • font switching
  • encircled
  • ideogram attributes 60-65

The colorize ruby library, for example, emits high intensity codes when using the "light" color options.

Colorizing Ruby RSpec Output

RSpec formatters detect whether RSpec is running in a terminal or not, therefore suppressing color output under Jenkins. Specify --colour --tty when calling rspec or add it to your .rspec file.

License

The ANSI Color Plugin is licensed under the MIT License.

It uses JANSI (Apache 2.0 License).

Contributing

See CONTRIBUTING.

ansicolor-plugin's People

Contributors

abrom avatar abxhr avatar basil avatar chetan avatar cpoenisch avatar darxriggs avatar dblock avatar dependabot[bot] avatar dwnusbaum avatar ejelly avatar harrah avatar jasonm23 avatar javawizard avatar jglick avatar joster-jambit avatar kcboschert avatar lemeurherve avatar markewaite avatar marlene01 avatar martinnowak avatar mkobit avatar pmhahn avatar qvicksilver avatar sethmilliken avatar sschuberth avatar takai avatar tarjei avatar timja avatar tszmytka avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ansicolor-plugin's Issues

Inverted color not being shown

As read here, the escape sequence \e[7m allow to invert the colors. In example:

RED='\e[31m'
INVERTED='\e[7m'
NORMAL='\e[0m'

if [ ! -f $HOME/_initilized ]; then
    echo -e "${RED}Some message\nMarking ${INVERTED}this text${NORMAL}."
    exit 1
fi

In bash this text is shown in red background and 'nocolor' foreground.
But the jenkins output is all in red color.

'Exception caught evaluating condition,' causes builds to fail ungracefully

I updated from 0.4.1 to the latest master, built at commit 689f6bc, because I wanted to start using the plugin with Jenkins Workflow jobs (support added in #54). Then my builds which had ANSI color enabled started failing silently. The build job's console log would just end abruptly with no error shown and the build marked as a failure. Finally I looked at the Jenkins service log and found:

2015-09-28 18:24:27.695457500 Sep 28, 2015 6:24:27 PM org.jenkins_ci.plugins.run_condition.BuildStepRunner logEvaluateException
2015-09-28 18:24:27.695459500 WARNING: Exception caught evaluating condition: [java.lang.NumberFormatException: For input string: "31m108 108 108 108 108 108 108 108 108 108 108 108 108 108 108"], action = [Fail the build]
2015-09-28 18:24:27.695461500 java.lang.NumberFormatException: For input string: "31m108 108 108 108 108 108 108 108 108 108 108 108 108 108 108"
2015-09-28 18:24:27.695461500   at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
2015-09-28 18:24:27.695483500   at java.lang.Integer.parseInt(Integer.java:492)
2015-09-28 18:24:27.695484500   at java.lang.Integer.<init>(Integer.java:677)
2015-09-28 18:24:27.695484500   at org.fusesource.jansi.AnsiOutputStream.write(AnsiOutputStream.java:120)
2015-09-28 18:24:27.695485500   at hudson.plugins.ansicolor.AnsiHtmlOutputStream.write(AnsiHtmlOutputStream.java:166)
2015-09-28 18:24:27.695485500   at java.io.FilterOutputStream.write(FilterOutputStream.java:125)
2015-09-28 18:24:27.695489500   at hudson.plugins.ansicolor.AnsiColorBuildWrapper$ConsoleLogFilterImpl$1.eol(AnsiColorBuildWrapper.java:222)
2015-09-28 18:24:27.695490500   at hudson.console.LineTransformationOutputStream.eol(LineTransformationOutputStream.java:60)
2015-09-28 18:24:27.695491500   at hudson.console.LineTransformationOutputStream.write(LineTransformationOutputStream.java:56)
2015-09-28 18:24:27.695497500   at hudson.console.LineTransformationOutputStream.write(LineTransformationOutputStream.java:74)
2015-09-28 18:24:27.695498500   at java.io.PrintStream.write(PrintStream.java:480)
2015-09-28 18:24:27.695498500   at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:221)
2015-09-28 18:24:27.695499500   at sun.nio.cs.StreamEncoder.implFlushBuffer(StreamEncoder.java:291)
2015-09-28 18:24:27.695500500   at sun.nio.cs.StreamEncoder.flushBuffer(StreamEncoder.java:104)
2015-09-28 18:24:27.695504500   at java.io.OutputStreamWriter.flushBuffer(OutputStreamWriter.java:185)
2015-09-28 18:24:27.695505500   at java.io.PrintStream.newLine(PrintStream.java:546)
2015-09-28 18:24:27.695505500   at java.io.PrintStream.println(PrintStream.java:807)
2015-09-28 18:24:27.695506500   at org.jenkins_ci.plugins.run_condition.core.BooleanCondition.runPerform(BooleanCondition.java:57)
2015-09-28 18:24:27.695507500   at org.jenkins_ci.plugins.run_condition.logic.ConditionContainer.runPerform(ConditionContainer.java:60)
2015-09-28 18:24:27.695524500   at org.jenkins_ci.plugins.run_condition.logic.Or.runPerform(Or.java:60)
2015-09-28 18:24:27.695525500   at org.jenkins_ci.plugins.run_condition.BuildStepRunner$2.evaluate(BuildStepRunner.java:107)
2015-09-28 18:24:27.695526500   at org.jenkins_ci.plugins.run_condition.BuildStepRunner$Fail.conditionalRun(BuildStepRunner.java:147)
2015-09-28 18:24:27.695533500   at org.jenkins_ci.plugins.run_condition.BuildStepRunner.perform(BuildStepRunner.java:105)
2015-09-28 18:24:27.695533500   at org.jenkinsci.plugins.conditionalbuildstep.singlestep.SingleConditionalBuilder.perform(SingleConditionalBuilder.java:108)
2015-09-28 18:24:27.695534500   at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
2015-09-28 18:24:27.695535500   at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:776)
2015-09-28 18:24:27.695539500   at hudson.model.Build$BuildExecution.build(Build.java:203)
2015-09-28 18:24:27.695539500   at hudson.model.Build$BuildExecution.doRun(Build.java:160)
2015-09-28 18:24:27.695540500   at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:536)
2015-09-28 18:24:27.695541500   at hudson.model.Run.execute(Run.java:1738)
2015-09-28 18:24:27.695541500   at hudson.matrix.MatrixRun.run(MatrixRun.java:146)
2015-09-28 18:24:27.695544500   at hudson.model.ResourceController.execute(ResourceController.java:98)
2015-09-28 18:24:27.695545500   at hudson.model.Executor.run(Executor.java:381)

Disabling ANSI color fixed the issue. Let me know if I can give you any other info to investigate.

Allow global setting

The plugin is very useful. The only thing that's nagging me is, that I have to enable it in every job. Given I have > 100 Jobs, this gets quite cumbersome ;)

What do you think about a global switch for enabling it per default?

Allow AnsiColor formatting via build artifact "view" link

Can we allow the artifact "view" link (/view/) on builds to leverage the AnsiColor plugin like console output? I've got logs including various ansi color escapes that'd be lovely to see in the web view, instead of currently requiring downloading the artifact and cat'ing to screen (in an ansi-capable terminal).

I'm willing to attempt it, but wanted to ask before diving in to see if those more familiar would either recommend against or could give pointers to speed up the effort (having not attempted any Jenkins plugin work before).

Not sure if this is still the right place to ask, so also requested in JENKINS-20417 (https://issues.jenkins-ci.org/browse/JENKINS-20417).

Reference text is garbled when ansicolor-plugin is enabled

On projects where ansicolor-plugin is enabled, at the very beginning of log I have garbled string instead of hyperlinks, like so:

Started by upstream project "�[8mha:AAAAoB+LCAAAAAAAAABb85aBtbiIQTGjNKU4P08vOT+vOD8nVc83PyU1x6OyILUoJzMv2y+/JJUBAhiZGBgqihhk0NSjKDWzXb3RdlLBUSYGJk8GtpzUvPSSDB8G5tKinBIGIZ+sxLJE/ZzEvHT94JKizLx0a6BxUmjGOUNodHsLgAy+EgYR/az8JH3fIEMDPZNEXZfgAF1jY30A3WJufskAAAA=�[0mjob" build number �[8mha:AAAAox+LCAAAAAAAAABb85aBtbiIQTGjNKU4P08vOT+vOD8nVc83PyU1x6OyILUoJzMv2y+/JJUBAhiZGBgqihhk0NSjKDWzXb3RdlLBUSYGJk8GtpzUvPSSDB8G5tKinBIGIZ+sxLJE/ZzEvHT94JKizLx0a6BxUmjGOUNodHsLgAzmEgZx/az8JH3fIEMDPZNEXZfgAF1jY30TCwsA+nx/DswAAAA=�[0m488

where 'job' and '488' are actual values which are normally made hyperlinks on the projects which don't have ansicolor enabled.

No color ouput with python environment

Hey, I have some strange problem with AnsiColor.

I can see colorized output in jenkins when I'm running simple (empty) project with something like this

echo -e "\e[31mRed Text\e[0m" echo -e "\e[42mGreen Background\e[0m"

But it does not work (even ANSI control codes not visible) when I'm running functional tests ??

What should I check first ?

this is how I run them

#!/bin/bash -ex
source /var/lib/jenkins/virtualenvs/testing-standard/bin/activate
DOMAIN=$DOMAIN sauron --name=website features/website.feature $SCENARIOS

Not seeing any parsing at all?

echo -e "Default \e[39mDefault\e[0m"
echo -e "Default \e[30mBlack\e[0m"
echo -e "Default \e[31mRed\e[0m"
echo -e "Default \e[32mGreen\e[0m"
echo -e "Default \e[33mYellow\e[0m"
echo -e "Default \e[34mBlue\e[0m"
echo -e "Default \e[35mMagenta\e[0m"
echo -e "Default \e[36mCyan\e[0m"
echo -e "Default \e[37mLight gray\e[0m"

Sent as a shell script build step, returns this console output (with Color ANSI Console Output checked of course!)

Started by user anonymous
Building in workspace /Users/jason/.jenkins/jobs/Ansi test/workspace
[workspace] $ /bin/sh -xe /var/folders/9w/f9101_t54l1gxj85b01twr4m0000gn/T/hudson4200421031759232690.sh
+ echo -e 'Default \e[39mDefault\e[0m'
-e Default \e[39mDefault\e[0m
+ echo -e 'Default \e[30mBlack\e[0m'
-e Default \e[30mBlack\e[0m
+ echo -e 'Default \e[31mRed\e[0m'
-e Default \e[31mRed\e[0m
+ echo -e 'Default \e[32mGreen\e[0m'
-e Default \e[32mGreen\e[0m
+ echo -e 'Default \e[33mYellow\e[0m'
-e Default \e[33mYellow\e[0m
+ echo -e 'Default \e[34mBlue\e[0m'
-e Default \e[34mBlue\e[0m
+ echo -e 'Default \e[35mMagenta\e[0m'
-e Default \e[35mMagenta\e[0m
+ echo -e 'Default \e[36mCyan\e[0m'
-e Default \e[36mCyan\e[0m
+ echo -e 'Default \e[37mLight gray\e[0m'
-e Default \e[37mLight gray\e[0m
Finished: SUCCESS

Same when using \033 instead of \e

... any ideas?

Plugin parses escape characters but doesn't add CSS - Python specific.

Hi guys,

I've read this thread: #49 and was almost going to comment on it, but for the sake of clarity I'll start a fresh one. I'll try keep it short and to the point.

Plugin is installed, works fine with following:
echo -e "\x1B[31mHello World\e[0m"
Returns:

Hello World

Which is in a span, with beautiful style="color: #CD0000;" applied.

I call a Python script from the same shell using the same escape sequences (I've tried three):
python -u /home/leeroy/jenkins/supersecretscript.py 123 -t

Here, the escape sequences are removed, but there's no HTML or CSS added... :(

To clarify, without ANSIColor the Python output is:

�[92mPass: �[0m Internal network OK

With ANSIColor :

Pass: Internal network OK

But 'Pass' is not colored in the latter, it's just been converted to plain text, it's not even in a span.

Any help is greatly appreciated.

BR,
Rich

How to use python scripts with ansicolor?

We converted a shell script to a python script in jenkins. However, the output changed from colored to this (snippet):

�[0;32m     Changes:   �[0;0m
�[0;32m----------�[0;0m

What are we missing?

Yellow and Cyan are unreadable on default Jenkins

From Jenkins Bug 11619:

The colors "yellow" and "cyan" are impossible to read on the white background.

May I suggest that you use class="ansicolor-cyan" instead of style="color: cyan"? This would allow someone to override the exact saturation/value of a color to make them readable.

By default, I'd suggest the following colors:

.ansicolor-cyan { color: #0AA; }
.ansicolor-yellow { color: #AA0; }

I don't have an example of all the different colors, magenta may also be a problem...

You could do this with all the various attributes, including 256 color ansi sequences, bold, underline, bright, etc.

.ansicolor-bold { font-weight: bold; }
.ansicolor-underline { text-decoration: underline; }
.ansicolor-bright { ...hmm...not sure... }

I'd be happy to help with the CSS...

IndexOutOfBoundsException: hudson.MarkupText.rangeCheck(MarkupText.java:277)


Caused by: java.lang.IndexOutOfBoundsException
    at hudson.MarkupText.rangeCheck(MarkupText.java:277)
    at hudson.MarkupText.addMarkup(MarkupText.java:260)
    at hudson.plugins.ansicolor.AnsiColorNote.annotate(AnsiColorNote.java:71)
    at hudson.console.ConsoleAnnotationOutputStream$1.annotate(ConsoleAnnotationOutputStream.java:115)
    at hudson.console.ConsoleAnnotator$1Aggregator.annotate(ConsoleAnnotator.java:111)
    at hudson.console.ConsoleAnnotationOutputStream.eol(ConsoleAnnotationOutputStream.java:145)
    at hudson.console.LineTransformationOutputStream.eol(LineTransformationOutputStream.java:60)
    at hudson.console.LineTransformationOutputStream.write(LineTransformationOutputStream.java:56)
    at hudson.console.LineTransformationOutputStream.write(LineTransformationOutputStream.java:74)
    at org.apache.commons.io.output.ProxyOutputStream.write(ProxyOutputStream.java:70)
    at org.apache.commons.io.output.CountingOutputStream.write(CountingOutputStream.java:71)
    at org.kohsuke.stapler.framework.io.LargeText$HeadMark.moveTo(LargeText.java:266)
    at org.kohsuke.stapler.framework.io.LargeText.writeLogTo(LargeText.java:181)
    at hudson.console.AnnotatedLargeText.writeHtmlTo(AnnotatedLargeText.java:158)
    at hudson.console.AnnotatedLargeText.writeLogTo(AnnotatedLargeText.java:145)
    at org.kohsuke.stapler.framework.io.LargeText.doProgressText(LargeText.java:216)
    at hudson.console.AnnotatedLargeText.doProgressiveHtml(AnnotatedLargeText.java:91)
    at sun.reflect.GeneratedMethodAccessor351.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:288)
    at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:151)
    at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:90)
    at org.kohsuke.stapler.MetaClass$1.doDispatch(MetaClass.java:111)
    at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:53)
    at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:574)
    ... 63 more

No coloured output in Jenkins 1.544 and plugin 0.3.1

First of all I don't see the Build Environment section in the Manage Jenkins -> System Configuration view, so there is no Color ANSI Console Output option to check nor the colour map to select.

On the other hand I can see the ANSI Color section, but that doesn't help.

Here is the list of plugins installed on my server:


  • AnsiColor
    This plugin adds support for ANSI escape sequences, including color, to Console Output.
    0.3.1
  • Ant Plugin
    This plugin adds Apache Ant support to Jenkins.
    1.2
  • Console Tail Plugin
    This plugin provides a tail view of the console on the main job page when the last build failed.
    1.1
  • Credentials Plugin
    This plugin allows you to store credentials in Jenkins.
    1.9.4
  • External Monitor Job Type Plugin
    Adds the ability to monitor the result of externally executed jobs.
    1.2
  • Git Parameter Plug-In
    Adds ability to choose from git repository revisions or tags
    0.2
  • Hudson Collapsing Console Sections Plugin
    This plugin allows the creation of sections in build consoles.
    1.4.1
  • Javadoc Plugin
    This plugin adds Javadoc support to Jenkins.
    1.1
  • Jenkins CVS Plug-in
    Integrates Jenkins with CVS version control system using a modified version of the Netbeans cvsclient.
    2.11
  • Jenkins GIT client plugin
    Shared library plugin for other Git related Jenkins plugins.
    1.6.0
  • Jenkins GIT plugin
    This plugin integrates GIT with Jenkins.
    2.0
  • Jenkins Mailer Plugin
    This plugin allows you to configure email notifications. This is a break-out of the original core based email component.
    1.8
  • Jenkins SSH Slaves plugin
    This plugin allows you to manage slaves running on *nix machines over SSH.
    1.5
  • Jenkins Subversion Plug-in
    This plugin adds the Subversion support (via SVNKit) to Jenkins.
    1.54
  • Jenkins Translation Assistance plugin
    This plugin adds an additional dialog box in every page, which enables people to contribute localizations for the messages they are seeing in the current page.
    1.10
  • LDAP Plugin
    Security realm based on LDAP authentication.
    1.7
  • Log Parser Plugin
    Parse the console output and highlight error/warning/info lines.
    1.0.8
  • Matrix Authorization Strategy Plugin
    Offers matrix-based security authorization strategies (global and per-project).
    1.1
  • Maven Integration plugin
    Jenkins plugin for building Maven 2/3 jobs via a special project type.
    2.1
  • PAM Authentication plugin
    Adds Unix Pluggable Authentication Module (PAM) support to Jenkins.
    1.1
  • SCM API Plugin
    This plugin provides a new enhanced API for interacting with SCM systems.
    0.2
  • SSH Credentials Plugin
    This plugin allows you to store SSH credentials in Jenkins.
    1.6
  • Static Analysis Utilities
    This plug-in provides utilities for the static code analysis plug-ins.
    If you like this open source plug-in please consider supporting my work by buying my Android game Inca Trails.
    1.54
  • Warnings Plug-in
    This plug-in collects the compiler warnings of the project modules and visualizes the results.
    4.38

And here is sample output I get:

[2013-12-30 09:45:19] [�[0;35mstderr�[0m] cp: cannot stat `rootfs/_output/*': No such file or directory
[2013-12-30 09:45:19] [�[0;94minfo�[0m] �[1;31mDYING: ERROR: deployment failed�[0m
[2013-12-30 09:45:19] [�[0;35mstderr�[0m] �[41mmake: *** [_deploy] Error 1�[0m
[2013-12-30 09:45:19] [�[0;94minfo�[0m] �[1;31mCall stack (most recent on the top):�[0m
[2013-12-30 09:45:19] [�[0;94minfo�[0m] �[1;31m---------- start: stack frame ----------�[0m
[2013-12-30 09:45:19] [�[0;94minfo�[0m] �[1;31m303 deploy ./_build.sh�[0m
[2013-12-30 09:45:19] [�[0;94minfo�[0m] �[1;31m228 with_logging ./_logging.sh�[0m
[2013-12-30 09:45:19] [�[0;94minfo�[0m] �[1;31m533 source ./_build.sh�[0m
[2013-12-30 09:45:19] [�[0;94minfo�[0m] �[1;31m35 main ./build.sh�[0m
[2013-12-30 09:45:19] [�[0;94minfo�[0m] �[1;31m�[0m

Support Powershell console colors

Powershell supports colors in its console output similar to other shells a la

Write-Host "Blue on Green!" -ForegroundColor Blue -BackgroundColor Green

It would be pretty freaking awesome if Powershell scripts run in Jenkins would display these output color choices. I am not a Java developer personally, but if this is easy enough to do I could take a swing at it. I could certainly test the feature if someone else implemented it.

AnsiColor not working

Hello,
I've problems while running colored output, as it is not colored.
I don't really get where the problem is; I don't get if it's a personal problem or not.

The actual setup:

  • Jenkins 1.554.3
  • Ubuntu Server 12.04
  • AnsiColor plugin 0.4.0
  • Snippet of code:
    echo -e "\e[31mRed Text\e[0m" echo -e "\e[42mGreen Background\e[0m"

Pipeline (formerly Workflow) snippet generator unhelpful

The snippet generator for wrap -> Color ANSI Console output gives a pretty unhelpful snippet:

wrap(<object of type hudson.plugins.ansicolor.AnsiColorBuildWrapper>) {
    // some block
}

The only place I found out how to use it was from your README.md :)

Set TERM variable to xterm

Hi!

Some programs (e. g. cmake's generated Makefiels) only output color, if the TERM env variable is set to a value like "xterm". I'm doing this manually atm, but it would be great if this plugin could set it automatically (if not already set).

mvn test fails (UTF-8)

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running hudson.plugins.ansicolor.AnsiColorizerTest
Tests run: 12, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.085 sec <<< FAILURE! - in hudson.plugins.ansicolor.AnsiColorizerTest
testUTF8Character(hudson.plugins.ansicolor.AnsiColorizerTest)  Time elapsed: 0.005 sec  <<< FAILURE!
java.lang.AssertionError: 
Expected: is "<b>?????</b>"
     got: "<b>?????</b>"

    at org.junit.Assert.assertThat(Assert.java:778)
    at org.junit.Assert.assertThat(Assert.java:736)
    at hudson.plugins.ansicolor.AnsiColorizerTest.testUTF8Character(AnsiColorizerTest.java:109)

UTF characters get messed up

I am wondering do you know what happens if I have some special char in the output looks like this when in "raw" mode of console output

screenshot

After being parsed by the plugin, it becomes:

screenshot

Is it possible for the plugin to maintain the characters? Thanks

'build.plugins.plugin.version' for com.cloudbees:maven-license-plugin is missing

[WARNING] Failed to build parent project for org.jenkins-ci.plugins:ansicolor:hpi:0.4.1-SNAPSHOT
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for org.jenkins-ci.plugins:ansicolor:hpi:0.4.1-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for com.cloudbees:maven-license-plugin is missing. @ org.jenkins-ci.plugins:plugin:1.424, /home/travis/.m2/repository/org/jenkins-ci/plugins/plugin/1.424/plugin-1.424.pom, line 191, column 15
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING] 

Promoting Status Console Output

Probably a change needed on the Promoted Builds plugin rather than this plugin (unless you can solve the global setting trick) but I noticed that the console output from promotions don't respond to ANSI codes. Promotions are where I currently do my Ruby bundling and such (with Ruby, I can put the whole pipeline inside a single project -- still testing if it is a good idea or not to do this).

Just something to think about and test if you ever find a way to intercept console output at a lower level.

New configurable colors breaks older logs.

When viewing logs from builds from before the latest ansicolor (the one where you can configure colors) you get this error in the logs:

Jun 06, 2012 10:19:55 AM hudson.ExpressionFactory2$JexlExpression evaluate
WARNING: Caught exception evaluating: it.writeLogTo(offset,output). Reason: java.lang.NullPointerException
java.lang.NullPointerException
at hudson.plugins.ansicolor.AnsiHtmlOutputStream.processSetForegroundColor(AnsiHtmlOutputStream.java:137)
at org.fusesource.jansi.AnsiOutputStream.processEscapeCommand(AnsiOutputStream.java:275)
at org.fusesource.jansi.AnsiOutputStream.write(AnsiOutputStream.java:125)
at hudson.plugins.ansicolor.AnsiHtmlOutputStream.write(AnsiHtmlOutputStream.java:91)
at java.io.FilterOutputStream.write(Unknown Source)
at hudson.plugins.ansicolor.AnsiHtmlOutputStream.writeLine(AnsiHtmlOutputStream.java:96)
at hudson.plugins.ansicolor.AnsiColorizer.eol(AnsiColorizer.java:51)
at hudson.plugins.ansicolor.AnsiColorNote.colorize(AnsiColorNote.java:79)
at hudson.plugins.ansicolor.AnsiColorNote.annotate(AnsiColorNote.java:58)
at hudson.console.ConsoleAnnotationOutputStream$1.annotate(ConsoleAnnotationOutputStream.java:115)
at hudson.console.ConsoleAnnotator$1Aggregator.annotate(ConsoleAnnotator.java:111)
at hudson.console.ConsoleAnnotationOutputStream.eol(ConsoleAnnotationOutputStream.java:145)
at hudson.console.LineTransformationOutputStream.eol(LineTransformationOutputStream.java:60)
at hudson.console.LineTransformationOutputStream.write(LineTransformationOutputStream.java:56)
at hudson.console.LineTransformationOutputStream.write(LineTransformationOutputStream.java:74)
at org.apache.commons.io.output.ProxyOutputStream.write(ProxyOutputStream.java:70)
at org.apache.commons.io.output.CountingOutputStream.write(CountingOutputStream.java:71)
at org.kohsuke.stapler.framework.io.LargeText.writeLogTo(LargeText.java:172)
at hudson.console.AnnotatedLargeText.writeHtmlTo(AnnotatedLargeText.java:158)
at hudson.model.Run.writeLogTo(Run.java:1172)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.commons.jexl.util.introspection.UberspectImpl$VelMethodImpl.invoke(UberspectImpl.java:258)
at org.apache.commons.jexl.parser.ASTMethod.execute(ASTMethod.java:104)
at org.apache.commons.jexl.parser.ASTReference.execute(ASTReference.java:83)
at org.apache.commons.jexl.parser.ASTReference.value(ASTReference.java:57)
at org.apache.commons.jexl.parser.ASTReferenceExpression.value(ASTReferenceExpression.java:51)
at org.apache.commons.jexl.ExpressionImpl.evaluate(ExpressionImpl.java:80)
at hudson.ExpressionFactory2$JexlExpression.evaluate(ExpressionFactory2.java:72)
at org.apache.commons.jelly.parser.EscapingExpression.evaluate(EscapingExpression.java:24)
at org.apache.commons.jelly.impl.ExpressionScript.run(ExpressionScript.java:66)
at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:161)
at org.apache.commons.jelly.tags.core.WhitespaceTag.doTag(WhitespaceTag.java:48)
at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:270)
at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
at org.kohsuke.stapler.jelly.ReallyStaticTagLibrary$1.run(ReallyStaticTagLibrary.java:99)
at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:161)
at org.apache.commons.jelly.tags.core.OtherwiseTag.doTag(OtherwiseTag.java:41)
at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:270)
at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:161)
at org.apache.commons.jelly.tags.core.ChooseTag.doTag(ChooseTag.java:38)
at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:270)
at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
at org.kohsuke.stapler.jelly.CallTagLibScript$1.run(CallTagLibScript.java:98)
at org.apache.commons.jelly.tags.define.InvokeBodyTag.doTag(InvokeBodyTag.java:91)
at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:270)
at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
at org.apache.commons.jelly.tags.core.CoreTagLibrary$1.run(CoreTagLibrary.java:98)
at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
at org.apache.commons.jelly.tags.core.CoreTagLibrary$2.run(CoreTagLibrary.java:105)
at org.kohsuke.stapler.jelly.CallTagLibScript.run(CallTagLibScript.java:119)
at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
at org.kohsuke.stapler.jelly.CallTagLibScript$1.run(CallTagLibScript.java:98)
[attaching 'main']
at org.apache.commons.jelly.tags.define.InvokeBodyTag.doTag(InvokeBodyTag.java:91)
at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:270)
at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
at org.kohsuke.stapler.jelly.ReallyStaticTagLibrary$1.run(ReallyStaticTagLibrary.java:99)
at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
at org.kohsuke.stapler.jelly.ReallyStaticTagLibrary$1.run(ReallyStaticTagLibrary.java:99)
at org.kohsuke.stapler.jelly.ReallyStaticTagLibrary$1.run(ReallyStaticTagLibrary.java:99)
at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
at org.kohsuke.stapler.jelly.ReallyStaticTagLibrary$1.run(ReallyStaticTagLibrary.java:99)
at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
at org.kohsuke.stapler.jelly.ReallyStaticTagLibrary$1.run(ReallyStaticTagLibrary.java:99)
at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
at org.apache.commons.jelly.tags.core.CoreTagLibrary$2.run(CoreTagLibrary.java:105)
at org.kohsuke.stapler.jelly.CallTagLibScript.run(CallTagLibScript.java:119)
at org.kohsuke.stapler.jelly.CompressTag.doTag(CompressTag.java:44)
at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:270)
at org.kohsuke.stapler.jelly.JellyViewScript.run(JellyViewScript.java:81)
at org.kohsuke.stapler.jelly.DefaultScriptInvoker.invokeScript(DefaultScriptInvoker.java:63)
at org.kohsuke.stapler.jelly.DefaultScriptInvoker.invokeScript(DefaultScriptInvoker.java:53)
at org.kohsuke.stapler.jelly.JellyFacet$1.dispatch(JellyFacet.java:95)
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:574)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:659)
at org.kohsuke.stapler.MetaClass$12.dispatch(MetaClass.java:384)
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:574)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:659)
at org.kohsuke.stapler.MetaClass$6.doDispatch(MetaClass.java:241)
at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:53)
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:574)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:659)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:488)
at org.kohsuke.stapler.Stapler.service(Stapler.java:162)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:95)
at hudson.plugins.greenballs.GreenBallFilter.doFilter(GreenBallFilter.java:58)
at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:98)
at hudson.util.PluginServletFilter.doFilter(PluginServletFilter.java:87)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at hudson.security.csrf.CrumbFilter.doFilter(CrumbFilter.java:47)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:84)
at hudson.security.UnwrapSecurityExceptionFilter.doFilter(UnwrapSecurityExceptionFilter.java:51)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:166)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at org.acegisecurity.ui.rememberme.RememberMeProcessingFilter.doFilter(RememberMeProcessingFilter.java:142)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:271)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at org.acegisecurity.ui.basicauth.BasicProcessingFilter.doFilter(BasicProcessingFilter.java:173)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at jenkins.security.ApiTokenFilter.doFilter(ApiTokenFilter.java:63)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249)
at hudson.security.HttpSessionContextIntegrationFilter2.doFilter(HttpSessionContextIntegrationFilter2.java:66)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at hudson.security.ChainedServletFilter.doFilter(ChainedServletFilter.java:76)
at hudson.security.HudsonFilter.doFilter(HudsonFilter.java:164)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.kohsuke.stapler.compression.CompressionFilter.doFilter(CompressionFilter.java:50)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:81)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:964)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1824)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

ability to detect and hyperlink file references

Imagine that your build process is generating some verbose logs which are saved as files.
It would be really nice if this plugin would recognize file references like dist/pip.log and hyperlink them so you could just click on the file to load it.

Output from Colorize Ruby gem doesn't appear colorized

Colored console output from the Colorize Ruby gem doesn't appear colorized in the Jenkins console.

In addition to the color code, the gem includes the mode and background color. Are these not supported?

"\033[#{color_parameters[:mode]};#{color_parameters[:color]+30};#{color_parameters[:background]+40}m#{color_parameters[:uncolorized]}\033[0m".set_color_parameters( color_parameters )

Thanks!

Allow to define a default background color as part of a color map

It would be nice if one could define a (named) default background color as part of a color map, e.g. "Black". In fact, one would probably need to be able to distinguish between the "dark" and "bright" flavors of a color. So as a first step, the according rows in the color map should be labeled "dark" / "bright" (or "low" / "high" or something), and then the background color could be chosen from a combo-box that contains "Black (dark)", "Black (bright)", "Red (dark)", "Red (bright)" and so on.

Too long Output Makes the Job Fail

We run a salt-ssh command which we pipe through tee. This preserves the color codes but somehow the job crashes. When the plugin is not active for the job the job runs well.

We cut the output in order to use the plugin (we like colors ;) ), but it seems like a bug.

Update description @ https://wiki.jenkins-ci.org/display/JENKINS/AnsiColor+Plugin

It's the first time that I use Pipeline, Jenkinsfile and the ansicolor plugin. It was very difficult for me to figure out how to add the plugin to the Jenkinsfile. Finally I found the solution here on github.
The problem was that the information on the official plugin page looks like the same as in the Readme but the part about how to add the plugin to the Jenkinsfile is missing.

I think there would be 2 possible solutions:

  • remove the information from the official plugin page and just link to the Readme
  • or keep the official plugin page up-to-date

Also the script generator did not help. It generates:
wrap(<object of type hudson.plugins.ansicolor.AnsiColorBuildWrapper>) { // some block }

Some escape sequences not recognized?

It seems some escape sequences are not recognized. This is what are Jenkins looks like if ANSI Color is not turned on

screen shot 2015-01-30 at 17 45 42

This is what it looks like with it turned on
screen shot 2015-01-30 at 17 45 28

As you can see, the first escape code (24) is recognized (no underline on next row), but the (39) escape code seems not to be. Any advice on how to fix or is this a bug?

log files get bloated with "junk" data

Hi, first of all thanks for you work on this plugin.

With the AnsiColor Plugin enabled our logfiles are getting huge with coloured output enabled.
In particular every line that has color sequences will add "junk" data to it, giving me:

Default �[8mha:AAAApR+LCAAAAAAAAP9b85aBtbiIQT2jNKU4P0+vIKc0PTOvWC8xrzgzOT8nv0gvODO3ICfVoyQ3xy+/JNU2Yj/Tagmf50wMjD4M7CWJ6SCJEgYhn6zEskT9nMS8dP3gkqLMvHTriiIGKaihyfl5xfk5qXrOEBpkDgMEMDIxMFQUlDDI2RQXJOYpFJdU5qTaKoEttlJQdnYxMHB2sVayAwDjW+2vpQAAAA==�[0mMagenta�[8mha:AAAAkR+LCAAAAAAAAP9b85aBtbiIQT2jNKU4P0+vIKc0PTOvWC8xrzgzOT8nv0gvODO3ICfVoyQ3xy+/JNU2Yj/Tagmf50wMjD4M7CWJ6SCJEgYhn6zEskT9nMS8dP3gkqLMvHTriiIGKaihyfl5xfk5qXrOEBpkDgMEMDIxMFQUlDCw2+gXFyTm2QEAI9P8iI4AAAA=�[0m

instead of (with color output disabled):

Default �[35mMagenta�[0m

for the script:

#!/bin/bash 
echo -e "Default \e[35mMagenta\e[0m"

I reproduced this on Debian Wheezy with the official jenkins repository (and java 7) in stock configuration to rule out a problem with our setup.

same problem was discussed in the comments here: https://issues.jenkins-ci.org/browse/JENKINS-11752

do you have any idea what could cause this and a possible solution / workaround?

thanks in advance.

Support high intensity ANSI colors

Does the plugin only support certain ANSI colors? I was looking through the source code and couldn't understand where the actual ANSI parsing/matching with the color map occurred. I only get stripped output. This is the HTML that gets generated:

<pre>
�[94m[�[92m ok �[94m]�[0m Test Search Body Text: "Not Allowed" passed [ ok ]
<span style="display: none;"> Test Search Body Text: "Not Allowed" passed �[94m[�[92m ok �[94m]�[0m </span>
Sensor DELETE Test
<span style="display: none;"> �[95mSensor DELETE Test�[0m </span>
Test Status 405 Method Not Allowed passed [ ok ]
<span style="display: none;"> Test Status 405 Method Not Allowed passed �[94m[�[92m ok �[94m]�[0m </span>
Test Search Body Text: "Not Allowed" passed [ ok ]
<span style="display: none;"> Test Search Body Text: "Not Allowed" passed �[94m[�[92m ok �[94m]�[0m </span>
Sensor GET without ID Test
<span style="display: none;"> �[95mSensor GET without ID Test�[0m </span>
Test Status 400 Bad Request passed [ ok ] 

http://imgur.com/pdZsT

Allow to detect whether the plugin is installed on Jenkins

In my rake build script I'm using STDOUT.tty? to check whether output is redirected to a file. In such a case, I disable ANSI color output in order to not add clutter to build log files. However, on Jenkins output also gets redirected and thus colored output is disabled.

With the plugin installed, I'd actually like to enable color output on Jenkins again, but still colored output should be disabled if I locally redirect build output to a file. I though of using STDOUT.tty? or ENV['JENKINS_HOME'] to check whether colored output should be used, but that would still clutter the Jenkins console on servers that do not have the plugin installed. Thus, IMHO the best solution would be to offer a way to detect whether the plugin is installed, e.g. by setting an environment variable, if that's possible.

AnsiColor interferes with console notes

Console notes use the "conceal" ANSI sequence to embed special markup into the log stream, see

https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/console/ConsoleNote.java

(note the PREAMBLE_STR and POSTAMBLE_STR constants). Right now, this means if you activate the AnsiColor plugin, the embedded data (i.e. "ha:base64-coded-data") will become visible as text, which makes reading the log quite hard.

Thus, AnsiColor should pass through sequences of «CSI»8m....«CSI»0m unchanged.

An example of such a sequence is this:

00005a0: 0a5b 494e 464f 5d20 1b5b 386d 6861 3a41  .[INFO] .[8mha:A
00005b0: 4141 4159 422b 4c43 4141 4141 4141 4141  AAAYB+LCAAAAAAAA
00005c0: 4142 6238 3561 4274 6269 4951 536d 6a4e  ABb85aBtbiIQSmjN
00005d0: 4b55 3450 302b 764a 4c45 3475 3167 7650  KU4P0+vJLE4u1gvP
00005e0: 6a65 784c 4456 507a 7864 4547 7676 6d5a  jexLDVPzxdEGvvmZ
00005f0: 2b58 3735 5a65 6b4c 6c4f 5666 7654 6a63  +X75ZekLlOVfvTjc
0000600: 3846 504a 6761 4769 6949 474b 6169 4735  8FPJgaGiiIGKaiG5
0000610: 5079 3834 7679 6356 4431 6e43 4131 5379  Py84vycVD1nCA1Sy
0000620: 4141 426a 4343 4642 5143 5632 374f 6a59  AABjCCFBQCV27OjY
0000630: 4141 4141 413d 3d1b 5b30 6d2d 2d2d 2062  AAAAA==.[0m--- b
0000640: 7569 6c64 6e75 6d62 6572 2d6d 6176 656e  uildnumber-maven
0000650: 2d70 6c75 6769 6e3a 312e 303a 6372 6561  -plugin:1.0:crea
0000660: 7465 2028 6465 6661 756c 7429 2040 2073  te (default) @ s
0000670: 7461 6765 322d 6d61 7665 6e2d 706c 7567  tage2-maven-plug
0000680: 696e 202d 2d2d 0a                        in ---.

Some output isn't interpreted correctly

I've got a problem where the plugin doesn't correctly render the output of a python library (pytest-sugar, a plugin to pytest).

As you can see from the screenshots below some of output is rendered correctly but the main block is showing up in raw escape sequences.

a
...snip...
b

The "correct" output in a terminal looks like this:
more like this

Here is the complete Jenkins output

The above was generated from the following minimized example:

cd ${WORKSPACE}
cat << EOF > test_blah.py
import time
import pytest

@pytest.mark.parametrize("i", list(range(20)))
def test_blah(i):
    time.sleep(.5)
EOF

pip install pytest pytest-sugar
py.test --color=yes test_blah.py

This should be run inside a "Virtualenv Builder" (nature: "shell") from the "ShiningPanda" Jenkins plugin.

java.lang.NoClassDefFoundError: jenkins/tasks/SimpleBuildWrapper

ansicolor plugin version 1.4.2 breaks on jenkins version 1.545 with the following error:

Mar 9, 2016 9:51:10 AM hudson.plugins.ansicolor.PluginImpl start
INFO: AnsiColor: eliminating boring output (https://github.com/dblock/jenkins-ansicolor-plugin)
Mar 9, 2016 9:51:10 AM jenkins.InitReactorRunner$1 onAttained
INFO: Prepared all plugins
Mar 9, 2016 9:51:16 AM hudson.ExtensionFinder$GuiceFinder$FaultTolerantScope$1 error
WARNING: Failed to instantiate Key[type=hudson.plugins.ansicolor.AnsiColorBuildWrapper$DescriptorImpl, annotation=[none]]; ski
pping this component
com.google.inject.ProvisionException: Guice provision errors:

1) Error injecting constructor, java.lang.NoClassDefFoundError: jenkins/tasks/SimpleBuildWrapper
  at hudson.plugins.ansicolor.AnsiColorBuildWrapper$DescriptorImpl.<init>(Unknown Source)

1 error
        at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:52)
        at com.google.inject.Scopes$1$1.get(Scopes.java:65)
        at hudson.ExtensionFinder$GuiceFinder$FaultTolerantScope$1.get(ExtensionFinder.java:429)
        at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:41)
        at com.google.inject.internal.InjectorImpl$3$1.call(InjectorImpl.java:1005)

Downgrading to version 1.4.1 works.

Don't create two markups (don't wrap existing markup)

Hello,

Thank you for the excellent plugin, I use it extensively with ruby colorize (after finding the critical troubleshooting information in Issue #5).

I have one question - what is the reasoning for creating 2 markups and then hiding one of them?
Specifically line 71 in AnsiColorNote.java

text.addMarkup(charPos, colorizedData);
text.addMarkup(charPos, charPos + text.getText().length(), "<span style=\"display: none;\">", "</span>");

This has been conflicting with an annotator I wrote (https://github.com/pmaccamp/file-url-annotator) as my html markup gets hidden inside the display:none tag. Apologies if the answer is obvious and I'm missing it.

Patrick

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.