自動化框架在本地跑都正常,文件也都讀取得到,但部署到Jenkins時卻報了以下錯誤:

Jenkins錯誤2.jpg
分析原因:
代碼中是通過以下方式獲取路徑:
protected static String projectPath = System.getProperty("user.dir");
protected static String filePath = projectPath + "http://files//UI自動化初始數(shù)據(jù).xls";
解決方法:
將maven配置中的workingDirectory內(nèi)容由target/改為.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.7</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/test/testng.xml</suiteXmlFile>
</suiteXmlFiles>
<properties>
<property>
<name>usedefaultlisteners</name>
<value>false</value>
</property>
<property>
<name>listener</name>
<value>org.uncommons.reportng.HTMLReporter,org.uncommons.reportng.JUnitXMLReporter</value>
</property>
</properties>
<workingDirectory>.</workingDirectory>
<forkMode>always</forkMode>
</configuration>
</plugin>