Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
189 views
in Technique[技术] by (71.8m points)

Get URL of error stacktrace page (on Jenkins web server) of each failed test case

In Jenkins job pipeline (implemented as Jenkins shared library), I am running PyTest for testing and then generating a JUnit XML report.

For every job build Jenkins has a test report page:

http://example.com/jenkins/job/<job_name>/<build_number>/testReport/

On this page I can see all tests that failed. If I click on particular testcase name, I see a page for that testcase with it's stacktrace and everything. Something like this:

http://example.com/jenkins/job/<job_name>/<build_number>/testReport/<package>.<file_name>/<className>/<testcase_name/

What I want is this URL. For every failed testcase I want the respective URL of Jenkins page on which I can see stacktrace and other info related to that failed testcase.

Basically, when my job runs with some testcase failing, I want to send email to developers and in that email I want these URLs so that from the email the developer directly jump to stacktrace page. In the job pipeline itself, I have a stage which sends this email.

So I need to generate these URLs in the job pipeline itself. I could not find any support from the Jenkins REST API that gives these URLs (there are plenty of ways to get the actual stacktrace itself but I want the URL to that stacktrace page)

Currently, I am manually generating these URL. I observed a pattern in these URLs like this:

http://example.com/jenkins/job/<job_name>/<build_number>/testReport/<package>.<file_name>/<className>/<testcase_name/

But it does not always work. Suppose if the testcase name has `[` or `]` or `/` or `package_name` is missing then this pattern is violated.

Is there any standard way to get all these URLs?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...