jenkins_get_job_status
Check the status of a specific Jenkins job to monitor CI/CD pipeline execution and identify build failures or successes.
Instructions
Obtener el estado de un job específico de Jenkins
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| app | Yes | Nombre de la aplicación | |
| branch | No | Rama de Git (por defecto: main) |
Implementation Reference
- tools/jenkins-service.ts:45-61 (handler)Core handler function in JenkinsService that performs the API call to retrieve the job status from Jenkins, including input validation and comprehensive error handling.async getJobStatus(app: string, branch: string = 'main'): Promise<JobStatus> { if (!validateAppName(app)) { throw new Error('Invalid app name. Only alphanumeric characters, hyphens and underscores are allowed.'); } const jobUrl = `${buildJobUrl('', app, branch)}/api/json`; try { const response: AxiosResponse<JobStatus> = await this.client.get(jobUrl); return response.data; } catch (error: any) { if (error.response?.status === 404) { throw new JenkinsError(`Job not found for app: ${app}, branch: ${branch} and url: ${jobUrl}`); } throw handleHttpError(error, `Failed to get job status for app: ${app}, branch: ${branch} and url: ${jobUrl}`); } }
- index.ts:38-70 (registration)MCP tool registration using server.tool, defining the tool name, description, input schema with Zod, and the inline handler that formats the response from the service."jenkins_get_job_status", "Obtener el estado de un job específico de Jenkins", { app: z.string().describe("Nombre de la aplicación"), branch: z.string().optional().describe("Rama de Git (por defecto: main)") }, async (args) => { try { const result = await getJenkinsService().getJobStatus(args.app, args.branch || 'main'); const lastBuild = result.lastBuild; const statusText = `🔧 **Estado del Job: ${result.displayName}**\n\n` + `**URL:** ${result.url}\n` + `**Estado:** ${result.color}\n` + `**Construible:** ${result.buildable ? '✅' : '❌'}\n` + `**Próximo build:** #${result.nextBuildNumber}\n\n` + (lastBuild ? `**Último build:** #${lastBuild.number}\n` + `**Resultado:** ${lastBuild.result || 'En progreso'}\n` + `**Duración:** ${formatDuration(lastBuild.duration || 0)}\n` + `**Timestamp:** ${formatTimestamp(lastBuild.timestamp || 0)}` : 'Sin builds previos'); return { content: [{ type: "text", text: statusText }], }; } catch (error: any) { return { content: [{ type: "text", text: `❌ **Error:** ${error.message}` }], }; } } );
- index.ts:40-42 (schema)Zod input schema defining parameters 'app' (required string) and 'branch' (optional string).{ app: z.string().describe("Nombre de la aplicación"), branch: z.string().optional().describe("Rama de Git (por defecto: main)")
- common/types.ts:7-22 (schema)TypeScript interface defining the structure of the JobStatus response from Jenkins API.export interface JobStatus { name: string; url: string; buildable: boolean; builds: Build[]; color: string; displayName: string; lastBuild?: Build; lastCompletedBuild?: Build; lastFailedBuild?: Build; lastStableBuild?: Build; lastSuccessfulBuild?: Build; lastUnstableBuild?: Build; lastUnsuccessfulBuild?: Build; nextBuildNumber: number; }