Skip to main content
Glama

triggerBuild

Start Jenkins job builds by specifying job names and parameters, including file paths, to automate continuous integration processes.

Instructions

Trigger a Jenkins job build with file and regular parameters

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
jobFullNameYesJenkins job name (e.g., "PlaywrightBDD")
parametersYesBuild parameters including file paths

Implementation Reference

  • The primary handler function that executes the tool logic: triggers a Jenkins job build, handles parameters (string/file), constructs FormData for API POST, extracts queue ID from response.
    export async function triggerBuild(client, args) {
    	const { jobFullName, parameters = {} } = args;
    	if (!jobFullName) return failure("triggerBuild", "jobFullName is required");
    	const jobPath = encodeURIComponent(jobFullName).replace(/%2F/g, "/");
    	const allowAbsolute = process.env.ALLOW_ABSOLUTE_FILE_PARAMS === "1";
    
    	try {
    		const form = new FormData();
    		const jsonParams = { parameter: [] };
    		let fileIndex = 0;
    
    		for (const [key, value] of Object.entries(parameters)) {
    			if (typeof value === "string") {
    				const potentialPath = value;
    				const isAbsolute = path.isAbsolute(potentialPath);
    				const withinCwd =
    					!isAbsolute || potentialPath.startsWith(process.cwd());
    				const exists =
    					withinCwd &&
    					fs.existsSync(potentialPath) &&
    					fs.statSync(potentialPath).isFile();
    
    				if (exists && (!isAbsolute || allowAbsolute)) {
    					const fileFieldName = `file${fileIndex}`;
    					form.append(
    						fileFieldName,
    						fs.createReadStream(potentialPath),
    						path.basename(potentialPath)
    					);
    					jsonParams.parameter.push({
    						name: key,
    						file: fileFieldName,
    					});
    					fileIndex++;
    					continue;
    				} else if (isAbsolute && !allowAbsolute && exists) {
    					return failure(
    						"triggerBuild",
    						`Absolute file paths are not allowed: ${potentialPath}. Set ALLOW_ABSOLUTE_FILE_PARAMS=1 to override.`
    					);
    				}
    			}
    
    			// Regular parameter fallback
    			jsonParams.parameter.push({ name: key, value: String(value) });
    		}
    
    		form.append("json", JSON.stringify(jsonParams));
    
    		const response = await client.post(
    			`${client.baseUrl}/job/${jobPath}/build`,
    			form,
    			{
    				headers: form.getHeaders(),
    				maxContentLength: Infinity,
    				maxBodyLength: Infinity,
    			}
    		);
    
    		if (response.status >= 200 && response.status < 300) {
    			const location =
    				response.headers["location"] || response.headers["Location"];
    			const queueId = location?.match(/queue\/item\/(\d+)/)?.[1] || null;
    			return success("triggerBuild", {
    				message: `Build triggered successfully for ${jobFullName}`,
    				queueUrl: location || null,
    				queueId,
    				statusCode: response.status,
    			});
    		}
    		return failure(
    			"triggerBuild",
    			`Build trigger returned status ${response.status}`,
    			{ statusCode: response.status, data: response.data }
    		);
    	} catch (error) {
    		return formatError(error, "triggerBuild");
    	}
    }
  • Input schema for the triggerBuild tool, specifying jobFullName (required string) and parameters (object with additional properties for flexibility).
    inputSchema: {
    	type: "object",
    	properties: {
    		jobFullName: {
    			type: "string",
    			description: 'Jenkins job name (e.g., "PlaywrightBDD")',
    		},
    		parameters: {
    			type: "object",
    			description: "Build parameters including file paths",
    			additionalProperties: true,
    		},
    	},
    	required: ["jobFullName", "parameters"],
    },
  • Tool registration in the central toolRegistry object, defining name, description, inputSchema, and references the handler function.
    triggerBuild: {
    	name: "triggerBuild",
    	description:
    		"Trigger a Jenkins job build with file and regular parameters",
    	inputSchema: {
    		type: "object",
    		properties: {
    			jobFullName: {
    				type: "string",
    				description: 'Jenkins job name (e.g., "PlaywrightBDD")',
    			},
    			parameters: {
    				type: "object",
    				description: "Build parameters including file paths",
    				additionalProperties: true,
    			},
    		},
    		required: ["jobFullName", "parameters"],
    	},
    	handler: triggerBuild,
    },
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions handling 'file and regular parameters', hinting at input types, but fails to describe critical behaviors like authentication needs, rate limits, side effects (e.g., queuing builds), or response format. This is a significant gap for a mutation tool with zero annotation coverage.

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

Conciseness4/5

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

The description is a single, efficient sentence that front-loads the core purpose. It avoids unnecessary words, though it could be slightly more structured (e.g., by separating key points) without adding bulk.

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 the complexity of triggering a Jenkins build (a mutation with parameters and no output schema), the description is incomplete. It lacks details on behavioral traits, error handling, and output expectations, leaving the agent under-informed. With no annotations and no output schema, the description should do more to compensate.

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 ('jobFullName' and 'parameters'). The description adds marginal value by noting 'file and regular parameters', which clarifies the scope of the 'parameters' object but doesn't provide syntax or format details beyond what the schema implies. 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 ('Trigger') and resource ('Jenkins job build'), specifying it handles both 'file and regular parameters'. It distinguishes from siblings like 'scheduleBuild' by emphasizing immediate triggering rather than scheduling, though it could be more explicit about this distinction.

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?

No explicit guidance on when to use this tool versus alternatives like 'scheduleBuild' or 'updateBuild'. The description implies usage for immediate builds with parameters, but lacks context on prerequisites, error conditions, or comparisons with sibling tools, leaving the agent to infer usage 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