rkk*_*ddy 31 jenkins jenkins-plugins
如何从Jenkins获取最新版本的构建时间戳?我想在post build actions中的Email主题中插入此值.
小智 24
构建时间戳插件将是获得TIMESTAMPS构建过程的最佳答案.
按照以下简单步骤"BUILD_TIMESTAMP"启用变量.
步骤1:
Manage Jenkins -> Plugin Manager -> Installed...
Search for "Build Timestamp Plugin".
Install with or without Restart.
Run Code Online (Sandbox Code Playgroud)
第2步:
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.
Run Code Online (Sandbox Code Playgroud)
用法:
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..
Run Code Online (Sandbox Code Playgroud)
Ale*_*lex 22
注意:这在Jenkins 1.597中已更改,请参阅此处以获取有关迁移的更多信息
您应该能够通过导航到查看构建期间可用的所有全局环境变量https://<your-jenkins>/env-vars.html.
替换https://<your-jenkins>/为您用于访问Jenkins网页的URL(例如,它可能是http://localhost:8080/env-vars.html).
其中一个环境变量是:
BUILD_ID
The current build id, such as "2005-08-22_23-59-59" (YYYY-MM-DD_hh-mm-ss)
Run Code Online (Sandbox Code Playgroud)
如果您使用jenkins可编辑的电子邮件通知,则应该可以${ENV, var="BUILD_ID"}在电子邮件的主题行中使用.
Asr*_*rar 10
一种方法是在全局环境部分使用 shell 脚本,在这里,我使用 UNIX 时间戳,但您可以使用任何 shell 脚本语法兼容的时间格式:
pipeline {
agent any
environment {
def BUILDVERSION = sh(script: "echo `date +%s`", returnStdout: true).trim()
}
stages {
stage("Awesome Stage") {
steps {
echo "Current build version :: $BUILDVERSION"
}
}
}
}
Run Code Online (Sandbox Code Playgroud)