[英]Groovy script to Grep a string from jenkins console output
我必須閱讀 jenkins 控制台 output 和 grep 具有字符串"%)"
的行。 我能夠使用以下代碼 grep 行:
def result = fileContents.findAll { it.contains('%)') }
println result*.toString()
Output:
× 35 of 45 failed (78%) 06:13 247 3 38 66 140
從上面的行中,我只需要獲取和打印失敗的 %。 IE。 78 並使 Jenkins 作業失敗,如果失敗的百分比高於 50%
有人可以使用 Groovy 幫助我嗎? 在不使用 Groovy 的情況下,還有其他方法對我來說也可以嗎?
根據我的說法,不要讓 groovy 腳本為您執行此操作(復雜的方式),請按照以下步驟操作:
wget <jenkins_url>
下載當前構建的控制台 output在您的情況下,您可以根據您的要求獲取成功/失敗百分比並通過/失敗階段。 希望這可以幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.