jenkins_get_git_branches
Retrieve available Git branches for a Jenkins job to configure builds or check code versions.
Instructions
Obtener las ramas de Git disponibles para un job
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| app | Yes | Nombre de la aplicación |
Implementation Reference
- tools/jenkins-service.ts:259-273 (handler)Core handler function in JenkinsService that fetches Git branches from the Jenkins GitParameterDefinition endpoint using a specific API call.async getGitBranches(app: string): Promise<string[]> { if (!validateAppName(app)) { throw new Error('Invalid app name.'); } // Para obtener branches, usamos el job principal sin branch específico const url = `${buildJobUrl('', app, 'main')}/descriptorByName/net.uaznia.lukanus.hudson.plugins.gitparameter.GitParameterDefinition/fillValueItems?param=BRANCH_TO_BUILD`; try { const response: AxiosResponse<{ values: GitBranch[] }> = await this.client.get(url); return response.data.values.map(branch => branch.name); } catch (error: any) { throw handleHttpError(error, `Failed to get Git branches for app: ${app}`); } }
- index.ts:368-391 (registration)MCP tool registration including schema (app: string), description, and thin handler that calls the service method and formats the markdown response."jenkins_get_git_branches", "Obtener las ramas de Git disponibles para un job", { app: z.string().describe("Nombre de la aplicación") }, async (args) => { try { const result = await getJenkinsService().getGitBranches(args.app); const branchesText = `🌿 **Ramas de Git Disponibles - ${args.app}**\n\n` + `**Total de ramas:** ${result.length}\n\n` + result.slice(0, 15).map((branch, index) => `${index + 1}. ${branch}`).join('\n') + (result.length > 15 ? `\n\n... y ${result.length - 15} ramas más` : ''); return { content: [{ type: "text", text: branchesText }], }; } catch (error: any) { return { content: [{ type: "text", text: `❌ **Error:** ${error.message}` }], }; } } );
- index.ts:370-372 (schema)Input schema definition for the tool using Zod: requires 'app' as string.{ app: z.string().describe("Nombre de la aplicación") },