getJobs
Retrieve a paginated list of Jenkins jobs with optional parent folder filtering and configurable result limits for job management.
Instructions
Get a paginated list of Jenkins jobs
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum number of items to return (default: 10, max: 10) | |
| parentFullName | No | Full path of the parent folder (optional) | |
| skip | No | Number of items to skip (default: 0) |
Implementation Reference
- src/tools/job-info.js:62-93 (handler)The main handler function that executes the getJobs tool logic. It fetches a paginated, sorted list of jobs from Jenkins API, handles pagination parameters, and returns formatted success or error responses.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)Tool registration in the central toolRegistry, defining the tool's name, description, input schema for validation, and linking to the handler function.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, },
- src/tools/index.js:173-190 (schema)Input schema defining the parameters for the getJobs tool: parentFullName (optional), skip, and limit for pagination.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)", }, }, },