jenkins_get_build
Retrieve a specific Jenkins build by its number or permalink (e.g., lastBuild) to inspect details and logs.
Instructions
Get a build by number or Jenkins permalink such as lastBuild.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| job | Yes | ||
| build | Yes | ||
| tree | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/jenkins_mcp_server/tools.py:132-139 (handler)The actual MCP tool handler for 'jenkins_get_build'. Decorated with @mcp.tool(), it takes a job path and build number/permalink, optionally a tree filter, and returns JSON data from the Jenkins build API.
@mcp.tool() def jenkins_get_build( job: str | list[str], build: int | str, tree: str | None = None, ) -> dict[str, Any]: """Get a build by number or Jenkins permalink such as lastBuild.""" return _run(lambda: _get_json(_build_path(job, build), params=_query(tree))) - src/jenkins_mcp_server/tools.py:55-55 (registration)The 'register_tools' function that decorates all tools with @mcp.tool() (line 55). All tool definitions including jenkins_get_build are nested inside this function.
def register_tools(mcp: FastMCP) -> None: - src/jenkins_mcp_server/tools.py:350-370 (registration)The READ_ONLY_TOOLS list that includes 'jenkins_get_build' (line 359), registering it as a read-only tool.
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 function used by jenkins_get_build to construct the URL path for a specific build by combining job_path and safe_segment.
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 job_path helper that converts a job name or list of path segments into a Jenkins API URL path (e.g., 'job/MyJob/job/subfolder'). Used by _build_path.
def job_path(job: str | list[str]) -> str: pieces = [piece for piece in job.split("/") if piece] if isinstance(job, str) else job if not pieces: raise PathValidationError("job must include at least one path segment") encoded: list[str] = [] for piece in pieces: if not piece or piece in {".", ".."} or "/" in piece: raise PathValidationError("job path segments must be non-empty names") encoded.extend(["job", quote(piece, safe="")]) return "/".join(encoded)