Jenkins Pipeline logs braces from ansiColor plugin?

徘徊边缘 提交于 2019-12-31 05:37:10

问题


I do not like that when I output a message using a ansiColor plug-in, it prints a lot of extra braces and words. How to fix it?

Jenkins Pipeline Method:

def printVariable(String message) {
ansiColor('xterm') {
    echo "\033[34m ${message} \033[0m"
}
}

Call:

printVariable("ENVIRONMENT: ${ENVIRONMENT}")
printVariable("PROJECT_VERSION: ${PROJECT_VERSION}")
printVariable("TAG_NAME: ${TAG_NAME}")

Output:

[Pipeline] }
[Pipeline] // ansiColor
[Pipeline] ansiColor
[Pipeline] {
[Pipeline] echo
 ENVIRONMENT: prod 
[Pipeline] }
[Pipeline] // ansiColor
[Pipeline] ansiColor
[Pipeline] {
[Pipeline] echo
 PROJECT_VERSION: 1.0.0 
[Pipeline] }
[Pipeline] // ansiColor
[Pipeline] ansiColor
[Pipeline] {
[Pipeline] echo
 TAG_NAME: repo.bla.bla
[Pipeline] }
[Pipeline] // ansiColor
[Pipeline] ansiColor
[Pipeline] {
[Pipeline] echo

I want it to be like this.

ENVIRONMENT: prod
PROJECT_VERSION: 1.0.0 
TAG_NAME: repo.bla.bla

Thanks for the help.


回答1:


We use the Simple Theme plugin to hide or surpress the pipeline annotated lines. With this you can use custom .css code to hide or don't display the pipeline annotated lines. You can do this if you have or installed this plugin via 'Jenkins > Manage Jenkins > Configure System' and navigate to 'Theme' and add Extra CSS.

For example this should not display the pipeline annotated lines:

.pipeline-annotated {
   display: none;
}

or just hide it (this will sometimes be more readable):

.pipeline-annotated {
   visibility: hidden;
}

See also this for more info.



来源:https://stackoverflow.com/questions/52456934/jenkins-pipeline-logs-braces-from-ansicolor-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!