热门搜索
还没有账号? 去注册 >
珠海副业副业网
如何从Jenkins构建变量中获取构建时间戳?,jenkins 构建失败
问题描述
如何从詹金斯获得额新版本的构建时间戳记?我想将此值插入电子邮件主题中.
额答案
注意:在Jenkins 1.597中发生了变化jenkins定时构建时间设置jenkins定时构建时间设置,请参见此处有关迁移的更多信息
您应该能够通过导航到/env-vars.html.
用您使用的URL替换/到jenkins网页(例如适合上班族创业的副业,它可以是:8080/env-vars.html).
环境变量之一是:
BUILD_ID The current build id, such as "2005-08-22_23-59-59" (YYYY-MM-DD_hh-mm-ss)
如果您使用Jenkins可编辑的电子邮件通知,则应可以在电子邮件的主题行中使用${ENV, var=”BUILD_ID”}.
其他额答案
构建时间戳插件将是在构建过程中获得TIMESTAMPS的额佳答案.
按以下简单步骤获取”BUILD_TIMESTAMP”变量.
步骤1:
Manage Jenkins -> Plugin Manager -> Installed... Search for "Build Timestamp Plugin". Install with or without Restart.
步骤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.
用法:
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..
其他额答案
这可以完成的一种方法是在额球环境部分中使用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" } } } }
读者福利:限时额费提供情感项目创业共赢,有执行力和2小时以上空闲时间的来,加微信: 446471435 →额了解咨询 !
无关联文章