Skip to main content
Glama

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
NameRequiredDescriptionDefault
jobFullNameYesFull path of the Jenkins job
buildNumberNoBuild number (optional, defaults to last build)

Implementation Reference

  • 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");
    	}
    }
  • 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,
    },
  • 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"],
    },

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/umishra1504/Jenkins-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server