getJobs
Retrieve a paginated list of Jenkins jobs to view and manage automation workflows, with options to filter by folder and control result display.
Instructions
Get a paginated list of Jenkins jobs
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| parentFullName | No | Full path of the parent folder (optional) | |
| skip | No | Number of items to skip (default: 0) | |
| limit | No | Maximum number of items to return (default: 10, max: 10) |
Implementation Reference
- src/tools/job-info.js:62-93 (handler)The handler function for the 'getJobs' tool. Fetches a list of Jenkins jobs from the specified parent folder (or root), sorts them alphabetically, applies pagination based on skip and limit parameters, and returns a formatted success response with the jobs list, total count, skip, and limit values. Handles errors appropriately.export async function getJobs(client, args = {}) { let { parentFullName = "", skip = 0, limit = 10 } = args; skip = Math.max(0, parseInt(skip, 10) || 0); limit = Math.min(10, Math.max(1, parseInt(limit, 10) || 10)); const basePath = parentFullName ? `/job/${encodeJobPath(parentFullName)}` : ""; try { const response = await client.get( `${basePath}/api/json?tree=jobs[name,url,description,buildable,color]` ); if (response.status === 200) { const jobs = response.data.jobs || []; const sortedJobs = jobs.sort((a, b) => a.name.localeCompare(b.name) ); const paginatedJobs = sortedJobs.slice(skip, skip + limit); return success("getJobs", { jobs: paginatedJobs, total: jobs.length, skip, limit, }); } return failure("getJobs", "Failed to get jobs", { statusCode: response.status, }); } catch (error) { return formatError(error, "getJobs"); } }
- src/tools/index.js:170-192 (registration)The registration of the 'getJobs' tool in the central tool registry. Includes the tool name, description, input schema for parameters (parentFullName, skip, limit), and reference to the handler function imported from job-info.js.getJobs: { name: "getJobs", description: "Get a paginated list of Jenkins jobs", inputSchema: { type: "object", properties: { parentFullName: { type: "string", description: "Full path of the parent folder (optional)", }, skip: { type: "integer", description: "Number of items to skip (default: 0)", }, limit: { type: "integer", description: "Maximum number of items to return (default: 10, max: 10)", }, }, }, handler: getJobs, },