pipelineUtils/vars/printBanner.groovy

57 lines
1.5 KiB
Groovy

void call(String stepName, Map styleMap = [:]) {
Map defaultStyleMap = [
boxColor: 'green',
textColor: 'white',
boxStyle: 'default'
]
runStyleMap = defaultStyleMap + styleMap
Map colors = [
black: '\u001b[30m',
red: '\u001b[31m',
green: '\u001b[32m',
yellow: '\u001b[33m',
blue: '\u001b[34m',
magenta: '\u001b[35m',
cyan: '\u001b[36m',
white: '\u001b[40;37m',
reset: '\u001b[0m',
]
Map boxStyles = [
default: [
tr: '╔',
tl: '╗',
sd: '║',
vr: '═',
br: '╚',
bl: '╜'
],
plain: [
tr: '+',
tl: '+',
sd: '|',
vr: '-',
br: '+',
bl: '+'
]
]
String textColor = runStyleMap['textColor']
String boxColor = runStyleMap['boxColor']
Map style = boxStyles[runStyleMap['boxStyle']]
stepBanner = style['sd'] + " ${colors[textColor]}$stepName${colors['reset']}${colors[boxColor]} " + style['sd']
bannerWidth = stepName.length() + 6
top = style['tr'] + (style['vr'] * bannerWidth) + style['tl']
bottom = style['br'] + (style['vr'] * bannerWidth) + style['bl']
ansiColor('css') {
echo "${colors[boxColor]}$top\n$stepBanner\n$bottom${colors['reset']}"
}
}
// ═ ║ ╒ ╓ ╔ ╕ ╖ ╗ ╘ ╙ ╚ ╛ ╜ ╝ ╞ ╟ ╠ ╡ ╢ ╣ ╤ ╥ ╦ ╧ ╨ ╩ ╪ ╫ ╬