getQueueInfo
Retrieve details about queued Jenkins builds to monitor pending jobs and manage build pipelines effectively.
Instructions
Get information about queued builds
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| jobFullName | No | Full path of the Jenkins job (optional, returns all queued items if not provided) |
Implementation Reference
- src/tools/queue-management.js:156-245 (handler)The handler function that retrieves Jenkins queue information, optionally filters by jobFullName, processes queue items with details like wait time, status, and returns formatted success or failure response.export async function getQueueInfo(client, args = {}) { const { jobFullName = null } = args; try { const queueResponse = await client.get( `${client.baseUrl}/queue/api/json` ); if (queueResponse.status !== 200) { return failure( "getQueueInfo", "Failed to fetch queue information", { statusCode: queueResponse.status } ); } const allItems = queueResponse.data.items || []; // If jobFullName is specified, filter for that job if (jobFullName) { const jobPath = encodeJobPath(jobFullName); const filteredItems = allItems.filter((item) => { if (item.task && item.task.url) { const itemJobPath = item.task.url .replace(client.baseUrl, "") .replace(/^\//, "") .replace(/\/$/, ""); const targetJobPath = `job/${jobPath}`.replace(/\/$/, ""); return itemJobPath === targetJobPath; } if (item.task && item.task.name) { const jobName = jobFullName.split("/").pop(); return ( item.task.name === jobFullName || item.task.name === jobName ); } return false; }); return success("getQueueInfo", { jobName: jobFullName, queueItems: filteredItems.map((item) => ({ id: item.id, why: item.why || "Waiting", stuck: item.stuck || false, blocked: item.blocked || false, buildable: item.buildable !== false, inQueueSince: new Date(item.inQueueSince).toISOString(), queuedFor: Math.floor((Date.now() - item.inQueueSince) / 1000) + " seconds", params: item.params, taskName: item.task?.name, taskUrl: item.task?.url, })), totalInQueue: filteredItems.length, }); } // Return all queue items return success("getQueueInfo", { queueItems: allItems.map((item) => ({ id: item.id, taskName: item.task?.name || "Unknown", taskUrl: item.task?.url, why: item.why || "Waiting", stuck: item.stuck || false, blocked: item.blocked || false, buildable: item.buildable !== false, inQueueSince: new Date(item.inQueueSince).toISOString(), queuedFor: Math.floor((Date.now() - item.inQueueSince) / 1000) + " seconds", params: item.params, })), totalInQueue: allItems.length, summary: { total: allItems.length, stuck: allItems.filter((i) => i.stuck).length, blocked: allItems.filter((i) => i.blocked).length, buildable: allItems.filter((i) => i.buildable !== false).length, }, }); } catch (error) { return formatError(error, "get queue info"); } }
- src/tools/index.js:293-307 (registration)Registration of the getQueueInfo tool in the central toolRegistry, including name, description, inputSchema for jobFullName (optional), and reference to the handler function.getQueueInfo: { name: "getQueueInfo", description: "Get information about queued builds", inputSchema: { type: "object", properties: { jobFullName: { type: "string", description: "Full path of the Jenkins job (optional, returns all queued items if not provided)", }, }, }, handler: getQueueInfo, },
- src/tools/index.js:296-305 (schema)Input schema definition for the getQueueInfo tool, specifying optional jobFullName parameter.inputSchema: { type: "object", properties: { jobFullName: { type: "string", description: "Full path of the Jenkins job (optional, returns all queued items if not provided)", }, }, },