2017-03-02 10 views
-2

複数のreport.htmlから "status"をgrepして複合レポートを作成する必要があります。これらのレポートは、以下のディレクトリに保存されます。 **で強調表示されているすべてのディレクトリは、レポートごとに異なります。どのように私はこれを達成することができます。 C:¥Program Files(x86)¥Jenkins¥jobs ** E2E_Sanity ** \ jobs ** ABC_E2E_Sanity ** \ builds ** 41 ** \ archive \ performanceTestsReports ** pcRun106821 ** \ Report複数のディレクトリをループしてステータスのhtmlファイルを読む

+0

?あなたの現在の実装についてもっと詳しく説明できますか? – Adonis

+1

Python Java Groovy ... 1つを選択 –

答えて

0

Pythonと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

は小さなグルービー番組を探すことができ:

  • 抽出修正行番号ワード用
  • 検索(ステータスは固定の行であれば) - ステータス情報を抽出するforループでrmation

    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 
         } 
        } 
    } 
    } 
    
関連する問題