listBuildArtifacts
Retrieve all artifacts from a specific Jenkins build or the most recent build to access generated files and outputs for analysis or deployment.
Instructions
List all artifacts from a specific build or the last build
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| jobFullName | Yes | Full path of the Jenkins job | |
| buildNumber | No | Build number (optional, defaults to last build) |
Implementation Reference
- src/tools/artifact-management.js:16-53 (handler)The main handler function that fetches and returns the list of artifacts from a Jenkins build using the Jenkins API. It handles both specific build numbers and the last build.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 tool registry, including 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 defining the expected 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"], },