2017-03-02 55 views
-2

我需要从多个report.html grep“状态”,并制作一个组合的报告,这些报告保存在下面的目录。用**突出显示的所有目录对于每个报告都不相同。我怎么能做到这一点。 C:\ Program Files(x86)\ Jenkins \ jobs ** E2E_Sanity ** \ jobs ** ABC_E2E_Sanity ** \ builds ** 41 ** \ archive \ performanceTestsReports ** pcRun106821 ** \ Report循环通过多个目录,并阅读状态的HTML文件

+0

有了一个for循环?你可以给你当前的实施更多的支持? – Adonis

+1

Python Java Groovy ...选择一个 –

回答

0

例如,使用蟒蛇和glob模块:

import glob 

files = r"C:\Program Files (x86)\Jenkins\jobs*\jobs*\builds*\archive\performanceTestsReports*\Report" 
l = glob.glob(files) 
for f in l: 
    print (f) 
0

找到一个小常规程序,可以:

  • 提取物修复行号(如果状态是在固定的行)
  • 搜索一个字 - 状态并提取信息息

    int lineNo = 1 
    //if the row number is fixed you can extracted by minLine and maxLine 
    int minLine = 1 
    int maxLine = 20 
    def line 
    def status 
    def statusRegex 
    
    
    def folder = new File("C:\\Users\\user\\Desktop\\ero") 
    
    folder.eachFile{it-> 
    println "File: ${it.absolutePath}" 
    
    it.withReader { reader-> 
        while ((line = reader.readLine()) != null & lineNo <= maxLine) { 
    
         if (lineNo >= minLine) { 
          //  println "${lineNo}. ${line}" //if you need specific line numbers 
         } 
         lineNo++ 
         //search for status and print the line 
         status = line.find("status") 
         //search for status by regex and extract all up to < 
         statusRegex = line.find(/(?s)status (.*?)\</) 
    
         if(status){ 
          println ' full line' + line 
         } 
         if(statusRegex){ 
          println ' by regex' + statusRegex 
         } 
        } 
    } 
    }