本文介绍了Jenkins Pipeline 从 ansiColor 插件记录大括号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不喜欢当我使用 ansiColor 插件输出消息时,它会打印很多额外的大括号和单词.如何解决?

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 流水线方法:

Jenkins Pipeline Method:

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

呼叫:

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

输出:

[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

我希望它是这样的.

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

感谢您的帮助.

推荐答案

我们使用 简单主题插件隐藏或隐藏管道注释行.有了这个,您可以使用自定义 .css 代码来隐藏或不显示管道注释行.如果您通过Jenkins > Manage Jenkins > Configure System"拥有或安装了此插件并导航到主题"并添加额外的 CSS,则可以执行此操作.

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;
}

另请参阅 this 了解更多信息.

See also this for more info.

这篇关于Jenkins Pipeline 从 ansiColor 插件记录大括号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 02:22