Skip to main content
Glama

stopBuild

Stop a running Jenkins build by specifying the job path and optional build number to halt execution and free resources.

Instructions

Stop/kill a running Jenkins build

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
jobFullNameYesFull path of the Jenkins job
buildNumberNoBuild number to stop (optional, defaults to last build)

Implementation Reference

  • The main handler function for the 'stopBuild' tool. It checks if the specified build is running, attempts a graceful stop via the Jenkins /stop endpoint, and falls back to a forceful kill via /kill if necessary. Handles errors and returns formatted success/failure responses.
    export async function stopBuild(client, args) {
    	const { jobFullName, buildNumber = null } = args;
    	const jobPath = encodeJobPath(jobFullName);
    	const buildPath = buildNumber || "lastBuild";
    
    	try {
    		// Get actual build number and check if build is running
    		const buildInfo = await client.get(
    			`${client.baseUrl}/job/${jobPath}/${buildPath}/api/json?tree=number,building,result,url`
    		);
    
    		if (buildInfo.status !== 200) {
    			return failure(
    				"stopBuild",
    				`Build not found: ${jobFullName}#${buildPath}`,
    				{ statusCode: buildInfo.status }
    			);
    		}
    
    		const actualBuildNumber = buildInfo.data.number;
    		const isBuilding = buildInfo.data.building;
    		const buildUrl = buildInfo.data.url;
    
    		if (!isBuilding) {
    			return failure(
    				"stopBuild",
    				`Build #${actualBuildNumber} is not currently running`,
    				{ buildResult: buildInfo.data.result, buildUrl }
    			);
    		}
    
    		// Try to stop the build (graceful stop)
    		const stopResponse = await client.post(
    			`${client.baseUrl}/job/${jobPath}/${actualBuildNumber}/stop`,
    			null
    		);
    
    		if (isSuccessStatus(stopResponse.status)) {
    			return success("stopBuild", {
    				message: `Build #${actualBuildNumber} stop request sent successfully`,
    				buildNumber: actualBuildNumber,
    				buildUrl,
    				action: "stop",
    			});
    		}
    
    		// If stop fails, try kill (forceful termination)
    		const killResponse = await client.post(
    			`${client.baseUrl}/job/${jobPath}/${actualBuildNumber}/kill`,
    			null
    		);
    
    		if (isSuccessStatus(killResponse.status)) {
    			return success("stopBuild", {
    				message: `Build #${actualBuildNumber} kill request sent successfully`,
    				buildNumber: actualBuildNumber,
    				buildUrl,
    				action: "kill",
    			});
    		}
    
    		return failure(
    			"stopBuild",
    			`Failed to stop build #${actualBuildNumber}`,
    			{ statusCode: stopResponse.status }
    		);
    	} catch (error) {
    		return formatError(error, "stopBuild");
    	}
    }
  • The registration of the 'stopBuild' tool in the central toolRegistry. Defines the tool's name, description, input schema (requiring jobFullName, optional buildNumber), and references the handler function.
    stopBuild: {
    	name: "stopBuild",
    	description: "Stop/kill a running Jenkins build",
    	inputSchema: {
    		type: "object",
    		properties: {
    			jobFullName: {
    				type: "string",
    				description: "Full path of the Jenkins job",
    			},
    			buildNumber: {
    				type: "integer",
    				description:
    					"Build number to stop (optional, defaults to last build)",
    			},
    		},
    		required: ["jobFullName"],
    	},
    	handler: stopBuild,
    },
  • The input schema for the stopBuild tool, defining the expected parameters: jobFullName (required string) and buildNumber (optional integer). Used for MCP tool validation.
    inputSchema: {
    	type: "object",
    	properties: {
    		jobFullName: {
    			type: "string",
    			description: "Full path of the Jenkins job",
    		},
    		buildNumber: {
    			type: "integer",
    			description:
    				"Build number to stop (optional, defaults to last build)",
    		},
    	},
    	required: ["jobFullName"],
    },
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It states the tool 'stop/kill a running Jenkins build,' implying a destructive mutation, but doesn't clarify if this is reversible, what permissions are required, or how it affects the build's status. This leaves significant gaps for a mutation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste—'Stop/kill a running Jenkins build'—making it front-loaded and easy to parse. Every word earns its place by specifying the action and target.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given this is a mutation tool with no annotations and no output schema, the description is incomplete. It lacks details on behavioral traits (e.g., effects, permissions), usage context, and return values, which are critical for safe and effective tool invocation in a Jenkins environment.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents both parameters fully. The description adds no additional meaning beyond implying the build must be 'running,' which is useful context but not detailed parameter semantics. Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('stop/kill') and resource ('a running Jenkins build'), making the tool's purpose immediately understandable. However, it doesn't differentiate from the sibling 'cancelQueuedBuild' tool, which appears to handle queued rather than running builds.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'cancelQueuedBuild' for queued builds or 'updateBuild' for modifying builds. It mentions the target is 'a running Jenkins build' but offers no context about prerequisites, permissions, or typical scenarios.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/umishra1504/Jenkins-mcp-server'

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