Skip to main content
Glama

scheduleBuild

Schedule Jenkins builds to run at specified times with custom parameters and file inputs for automated job execution.

Instructions

Schedule a Jenkins build with file and regular parameters to run at a specific time

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
jobFullNameYesJenkins job name (e.g., "PlaywrightBDD")
scheduleTimeYesWhen to run the build (e.g., 'in 5 minutes', 'at 3:30 PM', '2024-12-20 15:30')
parametersYesBuild parameters including file paths
descriptionNoOptional description for the scheduled build

Implementation Reference

  • The core handler function for the 'scheduleBuild' tool. It validates inputs, parses the schedule time, handles file and string parameters, constructs a FormData object, and schedules the build on Jenkins using a delay parameter in the API call.
    export async function scheduleBuild(client, args) {
    	const { jobFullName, parameters = {}, scheduleTime } = args;
    	if (!jobFullName)
    		return failure("scheduleBuild", "jobFullName is required");
    	if (!scheduleTime)
    		return failure("scheduleBuild", "scheduleTime is required");
    	const allowAbsolute = process.env.ALLOW_ABSOLUTE_FILE_PARAMS === "1";
    
    	let scheduledDate;
    	try {
    		scheduledDate = parseScheduleTime(scheduleTime);
    	} catch (e) {
    		return failure("scheduleBuild", e.message);
    	}
    	const now = new Date();
    	const delayInSeconds = Math.max(
    		0,
    		Math.floor((scheduledDate - now) / 1000)
    	);
    	const jobPath = encodeURIComponent(jobFullName).replace(/%2F/g, "/");
    
    	const form = new FormData();
    	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)) {
    				form.append(
    					key,
    					fs.createReadStream(potentialPath),
    					path.basename(potentialPath)
    				);
    				continue;
    			} else if (isAbsolute && !allowAbsolute && exists) {
    				return failure(
    					"scheduleBuild",
    					`Absolute file paths are not allowed: ${potentialPath}`
    				);
    			}
    		}
    		form.append(key, String(value));
    	}
    
    	try {
    		const res = await client.post(
    			`${client.baseUrl}/job/${jobPath}/buildWithParameters?delay=${delayInSeconds}sec`,
    			form,
    			{ headers: form.getHeaders(), maxBodyLength: Infinity }
    		);
    		if (res.status >= 200 && res.status < 300) {
    			return success("scheduleBuild", {
    				status: res.status,
    				queueUrl: res.headers.location,
    			});
    		}
    		return failure(
    			"scheduleBuild",
    			`Schedule returned status ${res.status}`,
    			{ statusCode: res.status }
    		);
    	} catch (error) {
    		return formatError(error, "scheduleBuild");
    	}
    }
  • The registration of the 'scheduleBuild' tool in the central toolRegistry object, including its name, description, input schema for validation, and reference to the handler function. This object is used by getAllTools() for MCP server registration.
    scheduleBuild: {
    	name: "scheduleBuild",
    	description:
    		"Schedule a Jenkins build with file and regular parameters to run at a specific time",
    	inputSchema: {
    		type: "object",
    		properties: {
    			jobFullName: {
    				type: "string",
    				description: 'Jenkins job name (e.g., "PlaywrightBDD")',
    			},
    			scheduleTime: {
    				type: "string",
    				description:
    					"When to run the build (e.g., 'in 5 minutes', 'at 3:30 PM', '2024-12-20 15:30')",
    			},
    			parameters: {
    				type: "object",
    				description: "Build parameters including file paths",
    				additionalProperties: true,
    			},
    			description: {
    				type: "string",
    				description: "Optional description for the scheduled build",
    			},
    		},
    		required: ["jobFullName", "scheduleTime", "parameters"],
    	},
    	handler: scheduleBuild,
    },
  • The inputSchema defining the expected parameters for the 'scheduleBuild' tool, including required fields jobFullName, scheduleTime, parameters, and optional description.
    inputSchema: {
    	type: "object",
    	properties: {
    		jobFullName: {
    			type: "string",
    			description: 'Jenkins job name (e.g., "PlaywrightBDD")',
    		},
    		scheduleTime: {
    			type: "string",
    			description:
    				"When to run the build (e.g., 'in 5 minutes', 'at 3:30 PM', '2024-12-20 15:30')",
    		},
    		parameters: {
    			type: "object",
    			description: "Build parameters including file paths",
    			additionalProperties: true,
    		},
    		description: {
    			type: "string",
    			description: "Optional description for the scheduled build",
    		},
    	},
    	required: ["jobFullName", "scheduleTime", "parameters"],
    },
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 scheduling with parameters but lacks critical details: it doesn't specify authentication needs, rate limits, whether the schedule is guaranteed or best-effort, how errors are handled, or what the response includes. For a mutation tool with zero annotation coverage, this is a significant gap in transparency.

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 that front-loads the core purpose ('Schedule a Jenkins build') and includes key modifiers without redundancy. Every phrase earns its place by specifying parameters and timing, making it appropriately sized and well-structured for quick comprehension.

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 scheduling a build (a mutation operation), no annotations, and no output schema, the description is incomplete. It doesn't cover behavioral aspects like permissions, error handling, or return values, and while the schema handles parameters well, the overall context for safe and effective use is lacking, making it inadequate for a tool with this level of responsibility.

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 all parameters thoroughly. The description adds minimal value beyond the schema by hinting at 'file and regular parameters' for the 'parameters' field, but doesn't provide additional syntax, format, or usage details. Baseline 3 is appropriate as 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 ('Schedule a Jenkins build') and specifies the resource ('Jenkins build'), including key aspects like 'with file and regular parameters' and 'to run at a specific time'. It distinguishes from siblings like 'triggerBuild' (immediate execution) by emphasizing scheduling, but doesn't explicitly name alternatives or detail scope differences beyond timing.

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

Usage Guidelines3/5

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

The description implies usage for deferred execution ('at a specific time'), suggesting it's for future builds rather than immediate ones. However, it doesn't explicitly state when to use this tool versus alternatives like 'triggerBuild' (for immediate builds) or 'cancelQueuedBuild' (for managing scheduled ones), nor does it mention prerequisites or exclusions, leaving some ambiguity.

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