如何在Jenkins中使用ANSIcolor插件? [英] How to use the ANSIcolor plugin in Jenkins?

查看:87
本文介绍了如何在Jenkins中使用ANSIcolor插件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为Jenkins安装了ANSI-color插件.在Jobs中,我已使用默认配置文件'xterm'激活了该插件.

我无法弄清楚在打印到控制台日志时如何给控制台日志的输出着色.从批处理文件记录日志(Windows平台).

关于

的文档

https://wiki.jenkins-ci.org/display/JENKINS/AnsiColor +插件

没有帮助.没有示例如何实际进行彩色打印.

我尝试了几种不同的echo/print命令,但是我无法使颜色起作用.

任何提示表示赞赏.

解决方案

ANSI色插件将您的控制台输出转换为HTML.如果您的输出包含ansi转义序列,则它将这些特殊的char序列转换为(彩色)HTML.您只能通过"ANSI颜色映射"配置映射.

示例:
\ x1b [31m 是将html颜色转换为红色

您的程序似乎没有使用转义序列.但是,如果您编写了自己的软件或脚本,则可以使用这些转义序列.

第一个示例BASH:

  echo -e"\ 033 [31mRed \ 033 [0m]" 

第二例BASH:

  printf"\ 033 [31mRed \ 033 [0m]" 

如果需要,您必须向printf添加换行符序列:

  printf"\ 033 [31mRed \ 033 [0m \ n" 

更多转义序列:
英语: http://en.wikipedia.org/wiki/ANSI_escape_code
Deutsch: http://de.wikipedia.org/wiki/Escape-Sequenz

I have installed the ANSI-color plugin for Jenkins. In the Jobs I have activated that plugin with the default profile 'xterm'.

I cannot figure out how to colorize the output of the Console Log when printing to the log from the batch files (Windows-platform).

The documentation on

https://wiki.jenkins-ci.org/display/JENKINS/AnsiColor+Plugin

is not helpful. There are no examples how to actually print in color.

I tried several different echo/print commands, but I cannot get colors to work.

Any hint appreciated.

解决方案

The ANSI-color plug in transforms your console output to HTML. If your output contains ansi escape sequences, then it converts these special char sequences into (colored) HTML. You can only configure the mapping via 'ANSI color map'.

Example:
\x1b[31m is transformes html color red

It looks that your program does't use Escape sequences. But if you wrote your own software or script, you can use these Escape sequences.

1st Example BASH:

echo -e "\033[31mRed\033[0m"

2nd Example BASH:

printf "\033[31mRed\033[0m"

If you need it, you have to add a newline sequence to printf:

printf "\033[31mRed\033[0m\n"

More to Escape sequences:
English: http://en.wikipedia.org/wiki/ANSI_escape_code
Deutsch: http://de.wikipedia.org/wiki/Escape-Sequenz

这篇关于如何在Jenkins中使用ANSIcolor插件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆