Skip to main content
Glama
xhuaustc

Jenkins MCP Tool

get_build_log

Retrieve build logs from Jenkins servers to analyze job execution details, troubleshoot failures, and monitor CI/CD pipeline performance.

Instructions

Get Jenkins build log.

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

Returns:
    Build log text

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
server_nameYes
job_full_nameYes
build_numberYes

Implementation Reference

  • MCP tool handler and registration for 'get_build_log'. Creates JenkinsAPIClient instance and calls its get_build_log method to retrieve the build console log.
    @mcp.tool()
    def get_build_log(server_name: str, job_full_name: str, build_number: int) -> str:
        """Get Jenkins build log.
    
        Args:
            server_name: Jenkins server name
            job_full_name: Full job name
            build_number: Build number
    
        Returns:
            Build log text
        """
        client = JenkinsAPIClient(server_name)
        return client.get_build_log(job_full_name, build_number)
  • Core implementation of get_build_log in JenkinsAPIClient. Fetches the build console log text from the Jenkins API endpoint /{build_number}/consoleText, handling 404 errors by raising JenkinsBuildNotFoundError.
    def get_build_log(self, job_full_name: str, build_number: int) -> str:
        """Get build log.
    
        Args:
            job_full_name: Full job name
            build_number: Build number
    
        Returns:
            Build log text
    
        Raises:
            JenkinsBuildNotFoundError: Build not found
            JenkinsError: API request failed
        """
        job_url = self._build_job_url(job_full_name)
        log_url = f"{job_url}/{build_number}/consoleText"
    
        response = self._make_request("GET", log_url)
    
        if response.status_code == 404:
            raise JenkinsBuildNotFoundError(
                build_number, job_full_name, self.server_name
            )
    
        response.raise_for_status()
        return response.text

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