框架部署到Jenkins时找不到指定路径

自动化框架在本地跑都正常,文件也都读取得到,但部署到Jenkins时却报了以下错误:


Jenkins错误2.jpg

分析原因:
代码中是通过以下方式获取路径:

protected static String projectPath = System.getProperty("user.dir");
protected static String filePath = projectPath + "//files//UI自动化初始数据.xls";

解决方法:
将maven配置中的workingDirectory内容由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>
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容