我已经安装了Description Setter插件,但是我不知道如何使用BUILD_ID。在jenkins/env-vars.html/中,它以“2005-08-22_23-59-59”(YYYY-MM-DD_hh-mm-ss)的格式显示。
有人知道我是否可以使用它以及如何使用吗?
如果无法显示BUILD_ID,则将其添加到构建描述中的最简单方法是什么?
谢谢!
我已经安装了Description Setter插件,但是我不知道如何使用BUILD_ID。在jenkins/env-vars.html/中,它以“2005-08-22_23-59-59”(YYYY-MM-DD_hh-mm-ss)的格式显示。
有人知道我是否可以使用它以及如何使用吗?
如果无法显示BUILD_ID,则将其添加到构建描述中的最简单方法是什么?
谢谢!
${BUILD_ID}
变量替换为构建编号,而不是时间戳(自1.597+以来)。请参见https://issues.jenkins-ci.org/browse/JENKINS-26520
还有一些其他插件的解决方法,比如EnvInject,或者你可以使用Description Setter插件的正则表达式功能,像这样:
echo“日期:”$(date +'%Y-%m-%d_%H-%M-%S')
- 将Description Setter插件设置为正则表达式
date:(.*)
- 将Description Setter插件设置为描述
\ 1
我的解决方案还演示了如何使用自定义链接作为描述。
Manage Jenkins -> Plugin Manager -> Installed...
Search for "Build Timestamp Plugin".
Install with or without Restart.
Manage Jenkins -> Configure System.
Search for 'Build Timestamp' section, then Enable the CHECKBOX.
Select the TIMEZONE, TIME format you want to setup with..Save the Page.
使用方法:
When Configuring the Build with ANT or MAVEN,
Please declare a Global variable as,
E.G. btime=${BUILD_TIMESTAMP}
(use this in your Properties box in ANT or MAVEN Build Section)
use 'btime' in your Code to any String Variables etc..
您可以使用Groovy令牌,例如:
${GROOVY,script = "String.format('%tF %<tH:%<tM', java.time.LocalDateTime.now())"}
它将在构建描述中添加时间戳,例如:2021-12-05 13:29
请注意,build.getTimestampString2()也会打印时间戳,但是根据UTC(在我的时区中早两个小时):2021-12-05T11:29:09Z
wmic os get LocalDateTime /VALUE 2^>NUL
) do if '.%%i.'=='.LocalDateTime.' set ldt=%%j set ldt=%ldt:0,4%-%ldt:4,2%-%ldt:6,2% %ldt:8,2%:%ldt:10,2%:%ldt:12,6% echo date: [%ldt%] - Maria