listBuildArtifacts
Retrieve all artifacts from a Jenkins build job, specifying either a particular build number or the most recent build.
Instructions
List all artifacts from a specific build or the last build
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| buildNumber | No | Build number (optional, defaults to last build) | |
| jobFullName | Yes | Full path of the Jenkins job |
Implementation Reference
- src/tools/artifact-management.js:16-53 (handler)The main asynchronous handler function that implements the logic to list build artifacts from a Jenkins job by querying the Jenkins API, processing the artifacts list, and returning a formatted success or failure response.export async function listBuildArtifacts(client, args) { const { jobFullName, buildNumber = null } = args; const jobPath = encodeJobPath(jobFullName); const buildPath = buildNumber || "lastBuild"; try { const response = await client.get( `/job/${jobPath}/${buildPath}/api/json?tree=artifacts[fileName,relativePath,displayPath],number,url,result,timestamp` ); if (response.status === 200) { const build = response.data; const artifacts = build.artifacts || []; return success("listBuildArtifacts", { buildNumber: build.number, buildUrl: build.url, buildResult: build.result, timestamp: build.timestamp, artifacts: artifacts.map((artifact) => ({ fileName: artifact.fileName, relativePath: artifact.relativePath, displayPath: artifact.displayPath || artifact.relativePath, downloadUrl: `${client.baseUrl}/job/${jobPath}/${build.number}/artifact/${artifact.relativePath}`, })), totalArtifacts: artifacts.length, }); } return failure( "listBuildArtifacts", `Build not found: ${jobFullName}#${buildPath}`, { statusCode: response.status } ); } catch (error) { return formatError(error, "list artifacts"); } }
- src/tools/index.js:216-236 (registration)The tool registration entry in the central toolRegistry object, defining the tool name, description, input schema for validation, and reference to the handler function.listBuildArtifacts: { name: "listBuildArtifacts", description: "List all artifacts from a specific build or the last build", inputSchema: { type: "object", properties: { jobFullName: { type: "string", description: "Full path of the Jenkins job", }, buildNumber: { type: "integer", description: "Build number (optional, defaults to last build)", }, }, required: ["jobFullName"], }, handler: listBuildArtifacts, },
- src/tools/index.js:220-234 (schema)The input schema definition for the listBuildArtifacts tool, specifying parameters jobFullName (required string) and optional buildNumber (integer).inputSchema: { type: "object", properties: { jobFullName: { type: "string", description: "Full path of the Jenkins job", }, buildNumber: { type: "integer", description: "Build number (optional, defaults to last build)", }, }, required: ["jobFullName"], },
- src/tools/index.js:14-17 (registration)Import statement registering the listBuildArtifacts handler function from artifact-management.js into the tools index module.import { listBuildArtifacts, readBuildArtifact, } from "./artifact-management.js";