jenkins_get_test_report
Retrieve JSON test report from a Jenkins job build that provides test results via plugins such as JUnit.
Instructions
Get /testReport/api/json when a test-report plugin such as JUnit provides it.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| job | Yes | ||
| build | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/jenkins_mcp_server/tools.py:160-163 (handler)The handler function for the 'jenkins_get_test_report' tool. It builds the path using _build_path and appends '/testReport', then fetches JSON via _get_json. The actual API call goes to Jenkins /testReport/api/json.
@mcp.tool() def jenkins_get_test_report(job: str | list[str], build: int | str) -> dict[str, Any]: """Get /testReport/api/json when a test-report plugin such as JUnit provides it.""" return _run(lambda: _get_json(f"{_build_path(job, build)}/testReport")) - src/jenkins_mcp_server/tools.py:160-163 (registration)Tool registration: the @mcp.tool() decorator on line 160 registers 'jenkins_get_test_report' as an MCP tool.
@mcp.tool() def jenkins_get_test_report(job: str | list[str], build: int | str) -> dict[str, Any]: """Get /testReport/api/json when a test-report plugin such as JUnit provides it.""" return _run(lambda: _get_json(f"{_build_path(job, build)}/testReport")) - src/jenkins_mcp_server/tools.py:350-370 (registration)The tool name is listed in the READ_ONLY_TOOLS list at line 362, grouping it with other read-only tools.
READ_ONLY_TOOLS = [ "jenkins_whoami", "jenkins_version", "jenkins_health", "jenkins_get_json", "jenkins_list_jobs", "jenkins_get_job", "jenkins_get_job_config", "jenkins_list_builds", "jenkins_get_build", "jenkins_get_build_log", "jenkins_get_build_artifacts", "jenkins_get_test_report", "jenkins_list_queue", "jenkins_get_queue_item", "jenkins_list_views", "jenkins_get_view", "jenkins_list_nodes", "jenkins_get_node", "jenkins_list_plugins", ] - The _build_path helper constructs the Jenkins job/build path segment used by the handler.
def _build_path(job: str | list[str], build: int | str) -> str: build_id = str(build) if not build_id or build_id in {".", ".."} or "/" in build_id: from .errors import PathValidationError raise PathValidationError("build must be a number or permalink path segment") return f"{job_path(job)}/{safe_segment(build_id, 'build')}" - The get_json method on JenkinsClient that the handler ultimately calls to fetch the test report JSON from the Jenkins API.
def get_json(self, path: str, params: Mapping[str, Any] | None = None) -> Json: response = self.request("GET", append_api_json(path), params=params) try: payload = response.json() except json.JSONDecodeError as exc: raise JenkinsHTTPError( response.status_code, "GET", normalize_relative_path(path), "Response was not JSON", _body_snippet(response), ) from exc return payload