Getting Jenkins build time when started

时光毁灭记忆、已成空白 提交于 2021-01-29 10:33:57

问题


I want to get the time when a build was started. I know the build name and number, but trick is the build may not have completed yet. The script can run on the Jenkins server or can be an API call. Any way I can accomplish that?


回答1:


You can install ZenTimestamp Plugin and get the time stamp using BUILD_TIMESTAMP variable added by this plugin.

Note:

  1. You need to specify SimpleDateFormat pattern (e.g. yyyyMMddHHmmss).
  2. You must activate the Global Property!



回答2:


Under the Jenkins job you will find Polling Log on the left hand side or you can just use the url like so jenkinsurl/job/jobName/buildNumber/pollingLog/pollingLog

All the details will be available here and you can find the time it started, by who,which revision ip address...




回答3:


Yes, you can use the Jenkins object to get the start time. For this inside your script.

Jenkins.getInstance().getItemByFullName(<your_job_name>).getBuildByNumber(<your_build_number>).getTime()


来源:https://stackoverflow.com/questions/50499318/getting-jenkins-build-time-when-started

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!