我正在编写Python脚本来过滤Jenkins控制台日志中的Jenkins作业,我想用正则表达式搜索特定的模式/文本。 以下是我要查找的文本:
somename.SomeTest.testSomeName()
以下段落或句子的一部分:
^{pr2}$以上这些句子在控制台日志中出现了20多次。我想找到
然后得到方法名somename.SomeTest.testSomeName()
。到目前为止,我已经尝试过了
缺少/不正确作为此正则表达式的一部分
下面是日志的小片段,我想从下面显示的每个日志中找出test method name
Failed to find the annotation....
句子:
21:18:19 at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:170)
21:18:19 at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:84)
21:18:19 at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:92)
21:18:19 at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200)
21:18:19 at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
21:18:19 at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
21:18:26 2016-05-12 21:18:25.238 [ERROR] (1): Failed to find the annotation and the status of the test public void com.somename.qa.mobile.tests.somename.SomeTest.testSomeName(). The result is not deployed to Platform but we will proceed with further tests
21:18:26 somename.client.test.utilities.Platform.PlatformApiException: Platform API returned HTTP 400("Field :case_id is not a valid test case.")
21:18:26 at somename.client.test.utilities.platform.PlatformApiClient.sendRequest(PlatformApiClient.java:197)
21:18:26 at
上面只是一个小片段;想象一下上面的片段在日志中出现了20多次。在
我想你可以扫描每行的输出。试试这个regexp
示例如何使用Perl(regexp是相同的)与您的示例一起工作
^{pr2}$说明
此正则表达式将执行以下操作:
[error]
查找所有行()
前面的三个文本块示例
现场示例
https://regex101.com/r/kI4cL2/1
示例文本
^{pr2}$样本匹配
解释
相关问题 更多 >
编程相关推荐