gpt4 book ai didi

Jenkins 脚本化管道使用全局时间戳选项

转载 作者:行者123 更新时间:2023-12-04 15:38:49 25 4
gpt4 key购买 nike

在我的脚本管道中,我想设置全局 timestampsansicolor 选项。

下面的脚本管道不工作。我们如何在脚本管道中添加这两个选项?

声明式管道

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"
}
}
}

最佳答案

在脚本管道的情况下,您所要做的就是用 timestampsansiColor('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"
}
}
}
}

enter image description here

关于Jenkins 脚本化管道使用全局时间戳选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58781364/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com