Timestamp mismatch in Jenkins Maven project

Viewed 73

I am using Jenkins version of 2.289.3. And I am working on a Maven-TestNG Selenium project in it. I have added Build Timestamp plugin and setup it in Manage Jenkins -> Configure System -> Build Timestamp with a pattern yyyy.MM.dd.HH.mm.ss of Asia/Calcutta. I am using Publish Html reports in Post Build action of that job's configuration. I have given path for HTML directory to archive is:

test-output\reports\report_${BUILD_TIMESTAMP}

But when running this job, the time stamp is not matching for publishing html report. End-portion of my comsole output is given below:

ChromeDriver was started successfully.
Aug 03, 2021 4:55:46 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 41.343 sec - in TestSuite

Results :

 Tests run: 4, Failures: 0, Errors: 0, Skipped: 0

  [WARNING] Could not delete temp directory 
  C:\Users\CS1027C\.jenkins\workspace\SeleniumTestNG\target\surefire because Directory 
  C:\Users\CS1027C\.jenkins\workspace\SeleniumTestNG\target\surefire unable to be deleted.
[JENKINS] Recording test results
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  01:05 min
[INFO] Finished at: 2021-08-03T16:56:22+05:30
[INFO] ------------------------------------------------------------------------
Waiting for Jenkins to finish collecting data
[JENKINS] Archiving C:\Users\CS1027C\.jenkins\workspace\SeleniumTestNG\pom.xml to 
MockTest/MockFrameTest/0.0.1-SNAPSHOT/MockFrameTest-0.0.1-SNAPSHOT.pom
channel stopped
[htmlpublisher] Archiving HTML reports...
 [htmlpublisher] Archiving at PROJECT level 
 C:\Users\CS1027C\.jenkins\workspace\SeleniumTestNG\test- 
output\reports\report_2021.08.03.16.54.51 to 
C:\Users\CS1027C\.jenkins\jobs\SeleniumTestNG\htmlreports\HTML_20Reports
ERROR: Specified HTML directory 'C:\Users\CS1027C\.jenkins\workspace\SeleniumTestNG\test- 
output\reports\report_2021.08.03.16.54.51' does not exist.
Build step 'Publish HTML reports' changed build result to FAILURE
Finished: FAILURE

Here the Chrome browser started at 4.55 but at post build action directory is created with timestamp containing 4.54. Why it is not taking the finishing time of the test? I can see a report folder generated at jenkins workspace is:

report_2021.08.03.16.55.36

Even I deleted the seconds from the time pattern, it is not matching with the generated report name. How can i fix this? Can anyone help me...Thanks in advance.

1 Answers

In my opinion the most probable explanation is as follows:

Build Timestamp plugin:

Export build timestamps to build env variables.

This is similar to setting environment variables via build parameters and the inline help of ☑ This project is parameterized reads:

Parameters allow you to prompt users for one or more inputs that will be passed into a build.

passed into a build“ means that the environment variable is set before the first build step starts.

The output of a Freestyle test project with the following Execute Windows batch command build step confirms this (Timestamp plugin pattern is set to HH:mm:ss,S):

@echo off
echo Build step begin: %time%
:: let 10 seconds pass 
ping -n 10 localhost > nul
echo Build step end: %time%
echo Build Timestamp: %BUILD_TIMESTAMP%

Console Output:

...
Build step begin: 21:19:33,88
Build step end: 21:19:42,90
Build Timestamp: 21:19:33,828
...
Related