ANSI colors in console does not work anymore

Hi,

Text remains white in logs on Travis whereas it still works on local.

It seems broken again since the 16th of December.

See https://github.com/travis-ci/travis-ci/issues/10112

You don’t have colors when you use secret variables.

That’s because the output is then fed to a filter program so it’s not to a terminal.

2 Likes

So I removed secret variable a long time ago, and it worked, thanks @native-api .

But now again I don’t see color anymore on Travis since around 3 months ago, though I haven’t changed my code that keeps working in Eclipse:


Last build with colors:
https://travis-ci.org/github/ron190/jsql-injection/jobs/635959361#L577

Maven seems to get in the way, I’ll post update when I find a fix.

Actually it does not, Maven logs are fine colored like the JUnit logs we see on the previous screenshot.
Though Maven version shouldn’t be around 3.1.1, because color does not appear with lower version.

So I upgraded to latest Maven version 3.6.3 in .travis.yml, but still no color.

Even the command mvn -v does not display the white version I see on my monitor:

image

On Travis it’s just plain grey #f1f1f1 so if there’s a filter it seems applied on top of Maven:

Any clue what’s happening?

With debug logging enabled, Maven reports which kind of logging is being used (corresponding source code). Check what yours produces to get a hint for localizing the issue.

[DEBUG] Message scheme: color
[DEBUG] Message styles: debug info warning error success failure strong mojo project

Also check (in the same log) if org.slf4j.* and org.fusesource.jansi.* are being imported which are both prerequisites for coloring.

If you get scheme: color then Maven’s output is being postprocessed. If you get scheme: plain or the prerequisites are missing then you are somehow messing with Maven’s installation and/or settings.

Thank you @native-api, I will check and test what you propose.

I did get coloring months ago like on this job, but I don’t remember having changed anything on the logger part since then:
https://travis-ci.org/github/ron190/jsql-injection/jobs/635959361

Also I never used slf4j or jansi, just log4j, so maybe another dependency is breaking down everything.
Let me check on my side, I’ll update the post when the fix is found.

@native-api I tried and run debug command mvn -X dependency:tree and I still got colorless on Travis:

[DEBUG] Message scheme: color

https://travis-ci.org/github/ron190/jsql-injection/jobs/675523959#L281

I don’t understand how my code or my dependencies can disable colors even before running tests.
It’s weird.

I’ll retry with all dependencies disabled.

I disabled every dependencies possible, nothing strange in dependency tree, but it’s still colorless.
https://travis-ci.org/github/ron190/jsql-injection/jobs/675683845

At first glance it does not seem related directly to configuration, neither to .travis.yml nor to pom.xml.

Additionally I reviewed past jobs, the last coloring job was #218, the next that exists is colorless and is the #220, the only configuration change is on .travis.yml. I simply added openjdk14 then removed it.

And strangely enough job #219 is missing on Travis dashboard, and maybe something went wrong there.

I would like to review Requests panel for job #219 but it goes until job #327 only.
https://travis-ci.org/github/ron190/jsql-injection/requests

I’ve cloned your repo and ran a build on master, and colors are there.

So this must be secret variables – this way or another.

E.g. I see the following in your .travis.yml:

addons:
  sonarcloud:
    organization: ron190-github
    token:
      secure: Fi8pYQTRDsIzBBKPTLHcAxkm0l0JcrZZvADbhwWG95lqKgtEtGI0OzWB5nFUBiOu5N20yrMPz/x4BUTyqr61xZiOocB9SH5ya4jqlraIlQW3WPH0enZ7e/g/JmqiAttuhzic7s12XQR5VwvAbG7ZkHa41liJ0nTd8HiLG7TOPep0hVTX/VZ/+K1B0FMJJVsMNMfhDsrtegxLryoeCSuKpwiAXXN2GkTtV2g1o1fxSmFMb0cepC/03Hskfp4ZxnHaY9yQfJISulTuxv9EUy5ecQZj+btf+QB3iNAwNFIE/xC6VeuCSrTJ01kG9w9DvY3W6z9NywxVHL5fJNDHcWsIz6/FpdNZgwxw6hIBQOimSa2/oXrPNyNR/bUyu6kQMFitDXWNxZj56yicqduNc46ni9NjsavCMlTJrdh/MYKB+C8e2IVa11QT988iTZo5C7MjUqUJU4gKBgdcn0jGZb20pxd7/Gtf4uMz7tp9mQRCTXpV6OSE85phwezledPud1f7/TG/QBrzZCL3YTMLhrDLhiratHweitPpr3da2+HrjSkdmunGdyufB+bseJP68ghjG5QpYBakjkJgkGYXd+S/r1NHmsGhbuk3/S0WtoYRhlAaBl3U8c7z8/lBcPhNbkQmfjIMolTjVdK61rQSads1b3kgVcImsux0IxEhUjowqag=

Thank you for your time on this one @native-api.

Then it’s even weirder because if both secret variable and plain secure token are making logs colorless then it means Maven colors are gone when we put addons: sonarcloud in .travis.yml :upside_down_face: (see quote).

Should it be at least colorless only for secret variable, or just as expected: colorful whatever plain or secure token?

I removed secret variable the 19th of december 2019 after viewing your comment about it, so I don’t have any Environment Variables anymore.

And you kept addons: sonarcloud in your fork and you still have colors…

So I commited Remove everything for coloring without getting colors:

language: java
services: docker
jdk: 
 - openjdk8
 - openjdk9
 - openjdk10
 - openjdk12
 - openjdk13

addons:
  sonarcloud:
    organization: ron190-github
    token:
      secure: Fi8...ag=

cache:
  directories:
    - $HOME/.m2
    - $HOME/.sonar/cache
    
before_install:
  - mvn -v
  - mvn -X dependency:tree
  - which mvn
  - find /usr -name '*jansi*' -exec ls -l {} \;

Then I commited Remove universe for coloring and now colors are back:

language: java
jdk: 
 - openjdk8
 
before_install:
  - mvn -v
  - mvn -X dependency:tree
  - which mvn
  - find /usr -name '*jansi*' -exec ls -l {} \;

I don’t understand, I also deleted cache before.
Why have you colors and I have not? Not the jdks? Not the cache?
Nope, I don’t get it.

Tried without services: docker and still no color.

So the attribute addons: sonarcloud erases colors on my account only :sweat:

Secret variables are only applied to the repo whose encryption key they use. In any other repo, they are ignored. So I forked your repo specifically to remove them from the equation.

I guess non-variable encrypted values also enable output filtering because the presence of any encrypted value technically means that the output has to be watched for its presence.

Not enabling filtering for non-variable encrypted values is going to be problematic because it would remove the safety net: in this case, the stock logic working with the secrets would instead need to watch out to not accidentally expose them – which will complicate development and debugging and error reporting and such.

Ok, I get why something is active on my account only. But I don’t get the purpose of filtering I guess.

In the first place why activate such filtering to process/hide a token from the log tab, whereas the very same token is displayed to everyone in the tab View config and in the Git repository.

Can we confirm that something has changed on Travis platform since job #218, where both sonarcloud:token and coloring were working fine together?

Is there a solution to use sonarcloud and Maven without losing colors?

I believe this happened in the meantime between #218 and #220:

2 Likes

Oh, that’s it @native-api , I was not aware of this, you are right, the dates are matching.

I’ll stop worrying finally and leave it like this, and hope Travis team will manage to do both coloring and secured token all together.

Many thanks for your help.

Pipeline that runs application inside container using docker run -t still displays colors with secrets correctly redacted strangely enough: #516.1

Github Actions has exactly the same behaviors:

  • No color on logs running at the root of pipeline
  • Colors displayed fine from container running inside pipeline

I guess with -t, the app inside gets true for isatty() thus decides to show their (true :wink:) colors.

1 Like

Travis Windows log has historically not been a real TTY (i.e. isatty() returns zero), but it does support ANSI/VT escape sequences for color. It can perhaps be enhanced to use the new ConPTY API introduced in Windows 1809 so that isatty() returns nonzero, although I’m not sure if Windows Server Core has it.

If you can force your program to emit colors using ANSI/VT escape sequences (but not with using the Windows Console API) then it should work. I’ve been using --gtest_color=yes with Google Test all this time.

Imprint