jenkins_stop_job
Stop a running Jenkins job by specifying the application name and build number. Ideal for managing CI/CD pipelines efficiently on the MCP-Jenkins server.
Instructions
Detener un job de Jenkins en ejecución
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| app | Yes | Nombre de la aplicación | |
| branch | No | Rama de Git (por defecto: main) | |
| buildNumber | Yes | Número del build a detener |
Implementation Reference
- tools/jenkins-service.ts:93-106 (handler)Core handler function that stops a Jenkins build by POSTing to the /stop endpoint using axios.async stopJob(app: string, buildNumber: number, branch: string = 'main'): Promise<string> { if (!validateAppName(app)) { throw new Error('Invalid app name.'); } const jobUrl = `${buildJobBuildUrl('', app, buildNumber, branch)}/stop`; try { await this.client.post(jobUrl); return `Job stopped successfully for app ${app}, build ${buildNumber}, branch ${branch}`; } catch (error: any) { throw handleHttpError(error, `Failed to stop job for app: ${app}, build: ${buildNumber}, branch: ${branch}`); } }
- index.ts:96-117 (registration)Registers the jenkins_stop_job tool with MCP server, defines input schema using Zod, and provides a thin wrapper handler that calls JenkinsService.stopJob and formats the response.server.tool( "jenkins_stop_job", "Detener un job de Jenkins en ejecución", { app: z.string().describe("Nombre de la aplicación"), buildNumber: z.number().describe("Número del build a detener"), branch: z.string().optional().describe("Rama de Git (por defecto: main)") }, async (args) => { try { const result = await getJenkinsService().stopJob(args.app, args.buildNumber, args.branch || 'main'); return { content: [{ type: "text", text: `🛑 **${result}**` }], }; } catch (error: any) { return { content: [{ type: "text", text: `❌ **Error:** ${error.message}` }], }; } } );
- index.ts:99-102 (schema)Input schema validation using Zod for app name, build number, and optional branch.{ app: z.string().describe("Nombre de la aplicación"), buildNumber: z.number().describe("Número del build a detener"), branch: z.string().optional().describe("Rama de Git (por defecto: main)")