I’m working on a Jenkins Maven project, and I need to include the time taken for the build to complete in the post-build email notification. However, I couldn’t find any Jenkins-defined environment variables or related plugins that provide this information directly.
I tried implementing a solution using a shell script, but it didn’t work as expected.
Is there any alternative approach to achieve this in Jenkins? Specifically, I want to calculate the build duration (in minutes and seconds) and include it in the email content sent after the build completes.
Here are some things I’ve already tried:
Checked for environment variables that might store the build duration—no luck. Looked into existing plugins that might help—couldn’t find any suitable ones. Attempted to calculate the time using a shell script, but the results were inconsistent.
I need to execute this as a Jenkins freestyle/Maven project and not as a pipeline project
Any suggestions or code snippets that could help me achieve this on Jenkins Maven Project?