create_pipeline_webhook
Set up a webhook to automatically trigger AWS CodePipeline actions by defining pipeline name, webhook name, target action, authentication, and event filters.
Instructions
Create a webhook for a pipeline to enable automatic triggering
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| authentication | Yes | Authentication method for the webhook | |
| authenticationConfiguration | No | Authentication configuration based on the authentication type | |
| filters | No | Event filters for the webhook | |
| pipelineName | Yes | Name of the pipeline | |
| targetAction | Yes | The name of the action in the pipeline that processes the webhook | |
| webhookName | Yes | Name for the webhook |
Implementation Reference
- The main handler function that implements the tool logic: creates a webhook for the specified AWS CodePipeline using putWebhook, registers it with registerWebhookWithThirdParty, and returns formatted response with details.export async function createPipelineWebhook( codePipelineManager: CodePipelineManager, input: { pipelineName: string; webhookName: string; targetAction: string; authentication: string; authenticationConfiguration?: { SecretToken?: string; AllowedIpRange?: string; }; filters?: Array<{ jsonPath: string; matchEquals?: string; }>; } ) { const { pipelineName, webhookName, targetAction, authentication, authenticationConfiguration = {}, filters = [] } = input; const codepipeline = codePipelineManager.getCodePipeline(); // Create the webhook const response = await codepipeline.putWebhook({ webhook: { name: webhookName, targetPipeline: pipelineName, targetAction: targetAction, filters: filters.map(filter => ({ jsonPath: filter.jsonPath, matchEquals: filter.matchEquals })), authentication, authenticationConfiguration } }).promise(); // Register the webhook await codepipeline.registerWebhookWithThirdParty({ webhookName }).promise(); // Extract webhook details safely const webhookDetails = { name: webhookName, url: response.webhook ? String(response.webhook.url) : undefined, targetPipeline: pipelineName, targetAction: targetAction }; return { content: [ { type: "text", text: JSON.stringify({ message: "Pipeline webhook created and registered successfully", webhookDetails }, null, 2), }, ], }; }
- The input schema defining parameters for the create_pipeline_webhook tool, including pipeline details, authentication, and filters.export const createPipelineWebhookSchema = { name: "create_pipeline_webhook", description: "Create a webhook for a pipeline to enable automatic triggering", inputSchema: { type: "object", properties: { pipelineName: { type: "string", description: "Name of the pipeline" }, webhookName: { type: "string", description: "Name for the webhook" }, targetAction: { type: "string", description: "The name of the action in the pipeline that processes the webhook" }, authentication: { type: "string", description: "Authentication method for the webhook", enum: ["GITHUB_HMAC", "IP", "UNAUTHENTICATED"] }, authenticationConfiguration: { type: "object", description: "Authentication configuration based on the authentication type", properties: { SecretToken: { type: "string", description: "Secret token for GITHUB_HMAC authentication" }, AllowedIpRange: { type: "string", description: "Allowed IP range for IP authentication" } } }, filters: { type: "array", description: "Event filters for the webhook", items: { type: "object", properties: { jsonPath: { type: "string", description: "JSON path to filter events" }, matchEquals: { type: "string", description: "Value to match in the JSON path" } }, required: ["jsonPath"] } } }, required: ["pipelineName", "webhookName", "targetAction", "authentication"], }, } as const;
- src/index.ts:61-63 (registration)Import of the handler function and schema from the tools module.createPipelineWebhook, createPipelineWebhookSchema } from "./tools/create_pipeline_webhook.js";
- src/index.ts:202-217 (registration)Dispatch/registration of the tool handler in the CallToolRequest switch statement.case "create_pipeline_webhook": { return await createPipelineWebhook(codePipelineManager, input as { pipelineName: string; webhookName: string; targetAction: string; authentication: string; authenticationConfiguration?: { SecretToken?: string; AllowedIpRange?: string; }; filters?: Array<{ jsonPath: string; matchEquals?: string; }>; }); }
- src/index.ts:124-126 (registration)Registration of the tool schema in the ListTools response array.createPipelineWebhookSchema, getPipelineMetricsSchema, ],