color works until halfway through 'start'
See original GitHub issueDescription
Maven colorized output works, until it stops working partway through the ‘start’ of docker-maven-plugin. But when docker-maven-plugin is finished, it remains broke through the rest of the build.
Info
All maven output colorized until the point shown below. But after that point, everything is NON colorized – including the entire maven build that has nothing to do with docker-maven-plugin.
10/06/18 09:44:26 [DEBUG] Configuring mojo 'io.fabric8:docker-maven-plugin:0.27.2:start' with basic configurator -->
10/06/18 09:44:26 [DEBUG] (f) autoCreateCustomNetworks = false
10/06/18 09:44:26 [DEBUG] (f) execution = io.fabric8:docker-maven-plugin:0.27.2:start {execution: prepare-flyway-dbserver}
10/06/18 09:44:26 [DEBUG] (s) name = obfuscated/postgres/postgres:10.3
10/06/18 09:44:26 [DEBUG] (f) alias = flyway-dbserver
10/06/18 09:44:26 [DEBUG] (f) ports = [flyway-dbserver.port:5432]
10/06/18 09:44:26 [DEBUG] (f) bind = [/var/lib/jenkins/workspace/obfuscated]
10/06/18 09:44:26 [DEBUG] (f) volumes = io.fabric8.maven.docker.config.RunVolumeConfiguration@1c4493c6
10/06/18 09:44:26 [DEBUG] (f) log = (?s)database system is ready to accept connections.*database system is ready to accept connections
10/06/18 09:44:26 [DEBUG] (f) time = 20000
10/06/18 09:44:26 [DEBUG] (f) postStart = /opt/build/flyway_db_setup.sh managementdb
10/06/18 09:44:26 [DEBUG] (f) exec = io.fabric8.maven.docker.config.WaitConfiguration$ExecConfiguration@41f5e6ee
10/06/18 09:44:26 [DEBUG] (f) wait = io.fabric8.maven.docker.config.WaitConfiguration@30c9ab3f
10/06/18 09:44:26 [DEBUG] (f) run = io.fabric8.maven.docker.config.RunImageConfiguration@5f5ab1ad
10/06/18 09:44:26 [DEBUG] (f) images = [ImageConfiguration {name='obfuscated/postgres/postgres:10.3', alias='flyway-dbserver'}]
10/06/18 09:44:26 [DEBUG] (f) keepContainer = false
10/06/18 09:44:26 [DEBUG] (f) logStdout = false
10/06/18 09:44:26 [DEBUG] (f) maxConnections = 100
10/06/18 09:44:26 [DEBUG] (f) project = MavenProject: obfuscated @ /var/lib/jenkins/workspace/obfuscated/pom.xml
10/06/18 09:44:26 [DEBUG] (f) removeVolumes = false
10/06/18 09:44:26 [DEBUG] (f) session = org.apache.maven.execution.MavenSession@521441d5
10/06/18 09:44:26 [DEBUG] (f) settings = org.apache.maven.execution.SettingsAdapter@4967d14c
10/06/18 09:44:26 [DEBUG] (f) skip = false
10/06/18 09:44:26 [DEBUG] (f) skipExtendedAuth = false
10/06/18 09:44:26 [DEBUG] (f) skipMachine = false
10/06/18 09:44:26 [DEBUG] (f) skipRun = false
10/06/18 09:44:26 [DEBUG] (f) startParallel = false
10/06/18 09:44:26 [DEBUG] (f) useColor = true
10/06/18 09:44:26 [DEBUG] (f) verbose = false
10/06/18 09:44:26 [DEBUG] -- end configuration --
all output above is colorized (i.e. the severity level is colorized, etc) all output below (and for the remainder of the entire build!!) is not colorized:
10/06/18 09:44:26 [DEBUG] DOCKER> Container create config: {"Image":"obfuscated/postgres/postgres:10.3","ExposedPorts":{"5432/tcp":{}},"Labels":{"dmp.coordinates":"obfuscated"},"HostConfig":{"PortBindings":{"5432/tcp":[{"HostPort":""}]},"Binds":["/var/lib/jenkins/workspace/obfuscated"],"VolumesFrom":[]},"Volumes":{"/opt/build":{}}}
Note details below – if we stifle debug output for the maven build, the problem does not occur. It’s something during the debug output that breaks coloring. But the break occurs at the point shown above. I have the useColor property set to true in the docker-maven-plugin config, didn’t help.
- d-m-p version : 0.27.2
- Maven version (
mvn -v
) : 3.5.4
- Docker version :17.06.2-ce
- If it’s a bug, how to reproduce : Reproduces all the time for me, though I’m not sure what the relevant factor is, I’m a little new to some of this. Potential factors: the entire build starts in a container already, before it gets to this step. I had to play a bit with setting env variables to get maven to generated color output in the first place, re: it not thinking it’s a tty, i.e. MVN_OPTS=-Dstyle.color=always -Djansi.force=true. But that works for the entire maven build up to the point where it breaks in the ‘start’ portion of this plugin.
Also – it looks like it’s something from debug output that breaks it. Specifically – if I run the maven build without the -X debug flag, the entire build remains colorized – before, during, and after the docker-maven-plugin actions. But when -X is enabled, everything is colorized up to the point shown in the output above, and then everything remains not colorized after that point – everything.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:9 (3 by maintainers)
really hoping this can be addressed. We have multiple maven projects, with all the output nice and colorized… until this plugin steps on everything and eliminates all colorized output for the remainder of the build, not playing nice with others. 😦
Our solution is pretty close - but slightly different. See below:
We let Maven install ANSI support itself it it has color enabled - reason why we don’t call
AnsiConsole.systemInstall()
ourselves. This way, standard Maven parameters can be used to turn color on/off for the whole Maven build.The only thing the plugin has to do is to turn off coloring for its own output if it needs to (questionable tho). This is done with
Ansi.setEnabled(false)
. This status is per-thread so the plugin must re-enable it when done otherwise the next plugin invocations won’t get any color anymore (the problem we are all facing)…We did this by overriding
AbstractDockerMojo
as follows:IMHO Maven should care about resetting the ANSI enabled state after each mojo invocation. This would be a good protection against rogue plugins…