Groovy\Jenkins 中是否有将毫秒转换为秒的单行代码
Is there a one liner to convert Milliseconds to Seconds in Groovy\Jenkins
我在 curl 命令中使用 ${currentBuild.duration}
并获取以毫秒为单位的构建持续时间,
有没有单排秒搞定的?
currentBuild.duration
成员访问器将 return 一个整型或长整型(以毫秒为单位)。因此,您可以使用算术运算符将其转换为秒:
currentBuild.duration / 1000
由于从您的问题看来您还想在插值中将其隐式转换为字符串,因此它看起来像:
"strings ${currentBuild.duration / 1000} strings"
我在 curl 命令中使用 ${currentBuild.duration}
并获取以毫秒为单位的构建持续时间,
有没有单排秒搞定的?
currentBuild.duration
成员访问器将 return 一个整型或长整型(以毫秒为单位)。因此,您可以使用算术运算符将其转换为秒:
currentBuild.duration / 1000
由于从您的问题看来您还想在插值中将其隐式转换为字符串,因此它看起来像:
"strings ${currentBuild.duration / 1000} strings"