目录
jenkins 彩色日志显示
示例:这里用到ansiColor插件,在Jenkins输出有颜色的日志信息
流水线语法的生成
ansiColor('xterm') {
// some block
}
tools.groovy
package org.devops
//格式化输出
def PrintMes(value,color){
colors = ['red' : "\033[40;31m >>>>>>>>>>${value}<<<<<<<<<< \033[0m",
'red1' : "\033[40;41m >>>>>>>>>>${value}<<<<<<<<<< \033[0m",
'green' : "\033[40;32m >>>>>>>>>>${value}<<<<<<<<<< \033[0m",
'green1' : "\033[40;42m >>>>>>>>>>${value}<<<<<<<<<< \033[0m",
'yellow' : "\033[40;33m >>>>>>>>>>${value}<<<<<<<<<< \033[0m",
'yellow1': "\033[40;43m >>>>>>>>>>${value}<<<<<<<<<< \033[0m",
'blue' : "\033[47;34m >>>>>>>>>>${value}<<<<<<<<<< \033[0m",
'blue1' : "\033[47;44m >>>>>>>>>>${value}<<<<<<<<<< \033[0m"
]
ansiColor('xterm') {
println(colors[color])
}
}
Jenkinsfile
@Library('jenkinslib') _
def tools = new org.devops.tools()
pipeline {
agent any
stages {
stage("hello"){
steps{
script{
tools.Post("success",'green')
}
}
}
}
}
转自
https://blog.csdn.net/weixin_44802620/article/details/125133847
标签:彩色,value,org,jenkins,日志,tools From: https://www.cnblogs.com/liwenchao1995/p/17274379.html