如何获取Jenkins构建作业工期 [英] How to get Jenkins build job duration

查看:25
本文介绍了如何获取Jenkins构建作业工期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用脚本或使用一些内置功能来获取Jenkins构建持续时间。我尝试使用${BUILD_DURATION},但不起作用。

有谁能推荐一下吗?

推荐答案

以下是几个选项:

RESTful API

使用您选择的语言使用Jenkins RESTful API以获取用于生成和反序列化的JSON。

声明性管道

使用${currentBuild.durationString}

currentBuild对象公开许多相关属性:

timeInMillis: 
    time since the epoch when the build was scheduled

startTimeInMillis
    time since the epoch when the build started running

duration
    duration of the build in milliseconds

durationString
    a human-readable representation of the build duration

导航到https://<your-jenkins-instance>/pipeline-syntax/globals#currentBuild以查看完整列表。

这篇关于如何获取Jenkins构建作业工期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆