Jenkins: Is there any API to see test reports remotely?
Use the XML or Json API. At most pages on Jenkins you can add /api/
to the url and get data in xml, json and similar formats. So for a job you can go to <Jenkins URL>/job/<Job Name>/api/xml
and get informaiton about the job, builds, etc. For a build you can go to <Jenkins URL>/job/<Job Name>/<build number>/api/xml
and you will get a summary for the build. Note that you can use the latestXXXBuild
in order to get the latest successful, stable, failing, complete build, like this; <Jenkins URL>/job/<Job Name>/lastCompletedBuild/api/xml
.
Additionally if youre using any plugin which publishes test results to the build, then for a given job you can go to <Jenkins URL>/job/<Job Name>/lastCompletedBuild/testReport/api/xml
and you will get an xml report with results.
There is a lot more to it, you can control what is exported with the tree
parameter and depth
parameter. For a summary go to <Jenkins URL>/api/
Well, if you are using a jenkins shared library or decided to permit the security exceptions (a less good approach) then you can access them via a job and send them out to whatever you like - push vs pull
def getCurrentBuildFailedTests() { def failedTests = [] def build = currentBuild.build() def action = build.getActions(hudson.tasks.junit.TestResultAction.class) if (action) { def failures = build.getAction(hudson.tasks.junit.TestResultAction.class).getFailedTests() println "${failures.size()} Test Results Found" for (def failure in failures) { failedTests.add(['name': failure.name, 'url': failure.url, 'details': failure.errorDetails]) } } return failedTests}