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?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…