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

ansiColor step inside withMaven: coloring is not kept after execution #223

Closed
joel-schaal opened this issue May 8, 2021 · 4 comments · Fixed by #226
Closed

ansiColor step inside withMaven: coloring is not kept after execution #223

joel-schaal opened this issue May 8, 2021 · 4 comments · Fixed by #226
Assignees
Labels

Comments

@joel-schaal
Copy link

Version report

Jenkins and plugins versions report:

Jenkins: 2.290
OS: Linux - 4.19.128-microsoft-standard
---
git-server:1.9
pipeline-milestone-step:1.3.2
jquery-detached:1.2.1
snakeyaml-api:1.27.0
build-monitor-plugin:1.12+build.201809061734
email-ext:2.82
scm-api:2.6.4
authentication-tokens:1.4
jsch:0.1.55.2
ssh-credentials:1.18.2
cloudbees-folder:6.15
external-monitor-job:1.7
ace-editor:1.1
bouncycastle-api:2.20
pipeline-maven:3.10.0
workflow-basic-steps:2.23
structs:1.22
docker-java-api:3.1.5.2
durable-task:1.36
workflow-durable-task-step:2.38
workflow-multibranch:2.23
config-file-provider:3.8.0
popper-api:1.16.1-2
mapdb-api:1.0.9.0
pipeline-graph-analysis:1.10
workflow-job:2.40
javadoc:1.6
envinject-api:1.7
docker-commons:1.17
jquery:1.12.4-1
workflow-aggregator:2.6
workflow-cps:2.90
authorize-project:1.4.0
workflow-scm-step:2.12
pipeline-input-step:2.12
copyartifact:1.46
script-security:1.76
docker-plugin:1.2.2
maven-plugin:3.10
workflow-api:2.42
gerrit-trigger:2.34.0
workflow-cps-global-lib:2.19
git-parameter:0.9.13
handlebars:3.0.8
slack:2.47
sonar-gerrit:2.4.3
bootstrap4-api:4.6.0-3
promoted-builds:3.9.1
credentials-binding:1.24
checks-api:1.7.0
junit:1.49
build-name-setter:2.2.0
plain-credentials:1.7
greenballs:1.15.1
conditional-buildstep:1.4.1
momentjs:1.1.1
trilead-api:1.0.13
display-url-api:2.3.4
git:4.7.1
jdk-tool:1.5
pipeline-stage-tags-metadata:1.8.4
git-client:3.7.1
subversion:2.14.1
uno-choice:2.5.6
credentials:2.3.18
workflow-step-api:2.23
ansicolor:0.7.5
pipeline-utility-steps:2.7.1
pipeline-model-definition:1.8.4
branch-api:2.6.4
token-macro:2.15
lockable-resources:2.10
pipeline-model-api:1.8.4
echarts-api:5.1.0-2
command-launcher:1.5
workflow-support:3.8
ldap:2.6
jquery3-api:3.6.0-1
windows-slaves:1.7
font-awesome-api:5.15.2-2
docker-workflow:1.26
sshd:3.0.3
plugin-util-api:2.1.0
apache-httpcomponents-client-4-api:4.5.13-1.0
jackson2-api:2.12.3
mailer:1.34
pam-auth:1.6
matrix-project:1.18
ssh-slaves:1.31.7
parameterized-trigger:2.40
pipeline-build-step:2.13
run-condition:1.5
h2-api:1.4.199
antisamy-markup-formatter:2.1
pipeline-rest-api:2.19
pipeline-stage-view:2.19
pipeline-stage-step:2.5
matrix-auth:2.6.6
envinject:2.4.0
pipeline-model-extensions:1.8.4
job-dsl:1.77
  • What Operating System are you using (both controller, and any agents involved in the problem)?
Windows 10, with Jenkins on Docker Desktop, no slave.

Reproduction steps

  • Setup a pipeline like that:
pipeline() {
  agent { node { label 'master' } }
  stages {
    stage('test ansiColor') {
      steps {
        withMaven(maven: 'maven-3') {
            ansiColor("xterm") {
                echo "\n\033[35;1mHello world\033[0m"
            }
        }
        sleep(3)
      }
    }
  }
}
  • Launch it and go to /console  of the run: the "Hello World" text is properly colored
  • Wait until the pipeline is finished, and go back to the /console of that run (not /consoleText)

Results

Expected result:

The text "Hello World" is displayed in magenta

Actual result:

The text "Hello World" was displayed unrendered (meaning: �[35;1mHello world�[0m)

@joel-schaal joel-schaal added the bug label May 8, 2021
@joel-schaal
Copy link
Author

I just found an acceptable workaround:

pipeline() {
  agent { node { label 'master' } }
  stages {
    stage('test ansiColor') {
      steps {
        ansiColor("xterm") {
            withMaven(maven: 'maven-3') {
                echo "\n\033[35;1mHello world\033[0m"
            }
        }
        sleep(3)
      }
    }
  }
}

tszmytka added a commit to tszmytka/ansicolor-plugin that referenced this issue May 13, 2021
@tszmytka
Copy link
Collaborator

Thanks for a very good report and investigation.
Much like #222 this is not really a ansicolor-plugin bug but rather the way pipeline-maven-plugin passes certain log lines without metadata makes it impossible to trigger coloring functionality.
Despite this I've added a similar workaround.

@joel-schaal
Copy link
Author

You're welcome !
I would have loved to propose a PR as well, but I'm not there yet...

It seems many plugins have this issue (of not relaying log lines properly, like #222, #193 and #201).
Isn't that a smell that there is something wrong with the architecture itself ? If many plugin developers choose not to relay the information properly, it may be because:

  • the proper way is not straight forward/intuitive enough or
  • the proper way is controversial

Do you think there is something to be done upstream ? I'm willing to help but I don't know exactly where I should start...
I read a bit on the issue regarding  ConsoleNote  (JENKINS-46324) and some analysis about its integration in Blue Ocean but I don't really know what to make of it.

Thanks for your ideas.

dblock pushed a commit that referenced this issue May 15, 2021
* #223 Work around withMaven step not passing on log line metadata

* Document changes
@joel-schaal
Copy link
Author

Awesome !
Thanks for the quick solving 🏎️🎉

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

Successfully merging a pull request may close this issue.

2 participants