问题
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