whoAmI
Retrieve details about the currently authenticated Jenkins user, including identity and permissions, to verify access and configure automation workflows.
Instructions
Get information about the current authenticated user
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/system-info.js:10-22 (handler)The handler function that implements the whoAmI tool logic. It makes an API call to /whoAmI/api/json to retrieve current user information and returns a standardized success or failure response.export async function whoAmI(client) { try { const response = await client.get("/whoAmI/api/json"); if (response.status === 200) { return success("whoAmI", { user: response.data }); } return failure("whoAmI", "Failed to get user info", { statusCode: response.status, }); } catch (error) { return formatError(error, "get user info"); } }
- src/tools/index.js:195-203 (registration)Registration of the whoAmI tool in the central toolRegistry. Includes name, description, empty input schema (no parameters required), and reference to the handler function.whoAmI: { name: "whoAmI", description: "Get information about the current authenticated user", inputSchema: { type: "object", properties: {}, }, handler: whoAmI, },
- src/tools/index.js:198-201 (schema)Input schema for the whoAmI tool, defining an empty object (no input parameters required).inputSchema: { type: "object", properties: {}, },
- src/utils/jenkins.js:113-140 (helper)Helper function formatError used in the whoAmI handler to standardize error responses.export function formatError(error, operation) { const status = error.response?.status; const errorInfo = { success: false, operation, message: error.message, statusCode: status, code: error.code, }; if (status === 403) { errorInfo.authError = true; errorInfo.message = "Permission denied - check job permissions or CSRF settings"; } else if (status === 401) { errorInfo.authError = true; errorInfo.message = "Authentication failed - check username and API token"; } else if (status === 404) { errorInfo.message = `Resource not found during ${operation}`; } if (error.response?.data && typeof error.response.data === "object") { errorInfo.responseData = error.response.data; } return errorInfo; }
- src/utils/jenkins.js:145-147 (helper)Helper function success used to wrap successful responses in whoAmI.export function success(operation, data = {}) { return { success: true, operation, ...data }; }
- src/utils/jenkins.js:152-154 (helper)Helper function failure used to wrap failure responses in whoAmI.export function failure(operation, message, meta = {}) { return { success: false, operation, message, ...meta }; }