问题
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:
- You need to specify SimpleDateFormat pattern (e.g.
yyyyMMddHHmmss
). - 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