Skip to main content
Glama

jenkins_get_coverage_lines

Retrieve code coverage line data for specific files from Jenkins CI/CD builds to analyze test coverage and identify untested code segments.

Instructions

Obtener líneas de cobertura de un archivo específico

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
appYesNombre de la aplicación
buildNumberYesNúmero del build
pathYesRuta del archivo
branchNoRama de Git (por defecto: main)

Implementation Reference

  • Main handler logic for fetching coverage lines of a specific file from Jenkins coverage report. Fetches frontend coverage report and extracts the file coverage data.
    async getCoverageReportLines(app: string, buildNumber: number, path: string, branch: string = 'main'): Promise<FileCoverage> { if (!validateAppName(app)) { throw new Error('Invalid app name.'); } try { const frontendReport = await this.getCoverageReportFrontend(app, buildNumber, branch); return this.getLinesByPath(frontendReport, path); } catch (error: any) { throw handleHttpError(error, `Failed to get coverage lines for app: ${app}, build: ${buildNumber}, path: ${path}, branch: ${branch}`); } }
  • index.ts:307-335 (registration)
    MCP tool registration including name, description, input schema, and thin wrapper handler that calls JenkinsService.getCoverageReportLines and formats output.
    "jenkins_get_coverage_lines", "Obtener líneas de cobertura de un archivo específico", { app: z.string().describe("Nombre de la aplicación"), buildNumber: z.number().describe("Número del build"), path: z.string().describe("Ruta del archivo"), branch: z.string().optional().describe("Rama de Git (por defecto: main)") }, async (args) => { try { const result = await getJenkinsService().getCoverageReportLines(args.app, args.buildNumber, args.path, args.branch || 'main'); const linesText = `📄 **Cobertura de Archivo: ${args.path}**\n\n` + `**Declaraciones:** ${Object.keys(result.statementMap).length}\n` + `**Funciones:** ${Object.keys(result.fnMap).length}\n` + `**Ramas:** ${Object.keys(result.branchMap).length}\n\n` + `**Líneas cubiertas:** ${Object.values(result.s).filter(v => v > 0).length}/${Object.keys(result.s).length}\n` + `**Funciones cubiertas:** ${Object.values(result.f).filter(v => v > 0).length}/${Object.keys(result.f).length}`; return { content: [{ type: "text", text: linesText }], }; } catch (error: any) { return { content: [{ type: "text", text: `❌ **Error:** ${error.message}` }], }; } } );
  • Input schema using Zod for validating tool parameters: app, buildNumber, path, branch.
    { app: z.string().describe("Nombre de la aplicación"), buildNumber: z.number().describe("Número del build"), path: z.string().describe("Ruta del archivo"), branch: z.string().optional().describe("Rama de Git (por defecto: main)")
  • Helper method to extract FileCoverage object for a specific path from the coverage report.
    private getLinesByPath(report: CoverageReportFront, path: string): FileCoverage { const file = Object.values(report.files).find(f => f.path.includes(path)); if (!file) { throw new Error(`File not found for path: ${path}`); } return file; }
  • Helper to fetch the frontend coverage report ZIP from Jenkins artifact.
    private async getCoverageReportFrontend(app: string, buildNumber: number, branch: string = 'main'): Promise<CoverageReportFront> { const zipUrl = `${buildJobBuildUrl('', app, buildNumber, branch)}/Coverage_20Unit_20Test_20Report/*zip*/Coverage_20Unit_20Test_20Report.zip`; const response = await this.client.get(zipUrl, { responseType: 'arraybuffer' }); // Aquí deberías extraer y procesar el ZIP // Por simplicidad, devolvemos un reporte vacío return { files: {} }; }

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/gcorroto/mcp-jenkins'

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