Skip to main content
Glama
xhuaustc

Jenkins MCP Tool

get_build_status

Retrieve Jenkins build status by specifying server name, job name, and build number to monitor CI/CD pipeline execution results.

Instructions

Get the Jenkins build status for the specified build_number.

Args:
    server_name: Jenkins server name
    job_full_name: Full job name
    build_number: Build number

Returns:
    Build status info

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
server_nameYes
job_full_nameYes
build_numberYes

Implementation Reference

  • MCP tool handler for 'get_build_status', registered via @mcp.tool() decorator. Creates JenkinsAPIClient and delegates to its get_build_status method.
    @mcp.tool()
    def get_build_status(server_name: str, job_full_name: str, build_number: int) -> dict:
        """Get the Jenkins build status for the specified build_number.
    
        Args:
            server_name: Jenkins server name
            job_full_name: Full job name
            build_number: Build number
    
        Returns:
            Build status info
        """
        client = JenkinsAPIClient(server_name)
        return client.get_build_status(job_full_name, build_number)
  • Core implementation in JenkinsAPIClient that queries the Jenkins API for the specific build's JSON data and returns structured BuildInfo.
    def get_build_status(self, job_full_name: str, build_number: int) -> BuildInfo:
        """Get build status.
    
        Args:
            job_full_name: Full job name
            build_number: Build number
    
        Returns:
            Build info
    
        Raises:
            JenkinsBuildNotFoundError: Build not found
            JenkinsError: API request failed
        """
        job_url = self._build_job_url(job_full_name)
        api_url = f"{job_url}/{build_number}/api/json"
    
        response = self._make_request("GET", api_url)
    
        if response.status_code == 404:
            raise JenkinsBuildNotFoundError(
                build_number, job_full_name, self.server_name
            )
    
        response.raise_for_status()
        data = response.json()
    
        return {
            "number": data.get("number", build_number),
            "result": data.get("result"),
            "building": data.get("building", False),
            "url": data.get("url", ""),
            "timestamp": data.get("timestamp", 0),
            "duration": data.get("duration", 0),
        }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/xhuaustc/jenkins-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server