在我编写脚本的管道中,我想设置全局timestamps和ansicolor选项。
以下脚本管道不工作。我们如何在脚本管道中添加这两个选项?
声明管道
pipeline {
agent none
options {
timestamps()
ansiColor('xterm')
}
stages {
stage('Checkout') {
agent { label 'linux' }
steps{
echo "test"
}
}
}
}脚本管道
node('linux') {
options {
timestamps()
ansiColor('xterm')
}
stage('Pre Build Setup') {
task('Display env') {
echo "test"
}
}
}发布于 2019-11-09 18:43:25
在脚本管道的情况下,只需使用timestamps和ansiColor('xterm')步骤包装脚本,如下例所示:
node {
timestamps {
ansiColor("xterm") {
stage("A") {
echo 'This is stage A'
sh 'printf "\\e[31mHello World\\e[0m\\n"'
sh "sleep 3s"
}
stage("B") {
echo "This is stage B"
}
}
}
}

https://stackoverflow.com/questions/58781364
复制相似问题