Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Unit testing Gerrit触发Jenkins构建时,目标目录上的时间戳不正确_Unit Testing_Maven_Jenkins_Gerrit - Fatal编程技术网

Unit testing Gerrit触发Jenkins构建时,目标目录上的时间戳不正确

Unit testing Gerrit触发Jenkins构建时,目标目录上的时间戳不正确,unit-testing,maven,jenkins,gerrit,Unit Testing,Maven,Jenkins,Gerrit,Jenkins没有报告我们的单元测试失败。以下是我们在构建日志中看到的内容: [JENKINS] Recording test results hudson.AbortException: Test reports were found but none of them are new. Did tests run? For example, /home/tomcat/.jenkins/jobs/ws-main-gerrit/workspace/commons/commons-utils/ta

Jenkins没有报告我们的单元测试失败。以下是我们在构建日志中看到的内容:

[JENKINS] Recording test results
hudson.AbortException: Test reports were found but none of them are new. Did tests run? 
For example, /home/tomcat/.jenkins/jobs/ws-main-gerrit/workspace/commons/commons-utils/target/surefire-reports/TEST-commons.utils.TransformationUtilsTest.xml is 32 min old
问题是,当Gerrit触发Jenkins构建时,它会创建具有错误(30分钟前)时间戳的目标目录。Jenkins和Gerrit所在服务器上的时间是正确的。当我登录并手动执行maven构建时,它会正确地报告单元测试中的失败

有什么想法会导致这个问题吗?

提前谢谢

问题在于Jenkins所在的NFS没有使用NTP(并且落后了大约30分钟),而系统的其他部分正在使用NTP。因此,这就是为什么date命令返回正确的时间戳,但目标目录中创建的文件使用错误的时间戳。

这个答案帮助我确定了问题,但我决定实施一种解决方法

我在Jenkins slave上运行了这个复合命令,以确定slave与其工作区使用的NFS装载之间存在差异:

$ date ; touch this ; ls -l this
Mon Nov 11 10:57:55 CST 2013
rw-rr- 1 davidg devtools 0 Nov 11 10:56 this
我在另一个VM/NFS挂载上尝试了相同的命令,但出现了相同的差异。我推测这是一个数据中心范围内的问题,可能很难很快解决,因此我决定通过使用“-t”选项的触摸命令手动更新文件的修改时间戳来解决这个问题

我在“ExecuteShell”构建步骤中添加了以下内容,Jenkins最终对我要发布的当前测试结果感到满意:

#!/bin/bash
echo $(hostname)
echo "Touching test results so that the Publish JUnit test result plugin always finds  new results..."
touch -m -t $(date "+%Y%m%d%H%M.%S") ${WORKSPACE}/myjob/target/surefire-reports/*.xml

你是怎么确定时间戳的?我被这件事缠住了。您能帮忙吗?我们在Jenkins服务器上更改了NFS以开始使用NTP。然后在服务器之间同步时间。谢谢,实际上我的svn配置是错误的。。因为它,我得到了这个时间戳不匹配。修好了。!!