trigger_build
Initiate a Jenkins CI/CD build by specifying the job path and optional parameters using this tool on the Jenkins Server MCP.
Instructions
Trigger a new Jenkins build
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| jobPath | Yes | Path to the Jenkins job | |
| parameters | Yes | Build parameters (optional) |
Implementation Reference
- src/index.ts:172-193 (handler)The handler function that implements the trigger_build tool. It constructs URL parameters from the input 'parameters' object and sends a POST request to the Jenkins job's buildWithParameters endpoint to trigger the build. Returns a success message.private async triggerBuild(args: any) { const params = new URLSearchParams(); if (args.parameters) { Object.entries(args.parameters).forEach(([key, value]) => { params.append(key, String(value)); }); } await this.axiosInstance.post( `/${args.jobPath}/buildWithParameters`, params ); return { content: [ { type: 'text', text: 'Build triggered successfully', }, ], }; }
- src/index.ts:83-97 (schema)Input schema for the trigger_build tool, requiring 'jobPath' (string) and 'parameters' (object). Defines the expected input structure for validation.inputSchema: { type: 'object', properties: { jobPath: { type: 'string', description: 'Path to the Jenkins job', }, parameters: { type: 'object', description: 'Build parameters (optional)', additionalProperties: true, }, }, required: ['jobPath', 'parameters'], },
- src/index.ts:80-98 (registration)Registration of the trigger_build tool in the ListTools response, including name, description, and input schema.{ name: 'trigger_build', description: 'Trigger a new Jenkins build', inputSchema: { type: 'object', properties: { jobPath: { type: 'string', description: 'Path to the Jenkins job', }, parameters: { type: 'object', description: 'Build parameters (optional)', additionalProperties: true, }, }, required: ['jobPath', 'parameters'], }, },