Skip to content

Commit aa31fa8

Browse files
feat(codepipeline): add AWS CodePipeline integration with tools and block
1 parent f7811f8 commit aa31fa8

38 files changed

Lines changed: 3299 additions & 94 deletions

apps/docs/components/icons.tsx

Lines changed: 65 additions & 37 deletions
Large diffs are not rendered by default.

apps/docs/components/ui/icon-mapping.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import {
3434
CloudFormationIcon,
3535
CloudflareIcon,
3636
CloudWatchIcon,
37+
CodePipelineIcon,
3738
ConfluenceIcon,
3839
CrowdStrikeIcon,
3940
CursorIcon,
@@ -241,6 +242,7 @@ export const blockTypeToIconMap: Record<string, IconComponent> = {
241242
cloudflare: CloudflareIcon,
242243
cloudformation: CloudFormationIcon,
243244
cloudwatch: CloudWatchIcon,
245+
codepipeline: CodePipelineIcon,
244246
confluence: ConfluenceIcon,
245247
confluence_v2: ConfluenceIcon,
246248
crowdstrike: CrowdStrikeIcon,
Lines changed: 237 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,237 @@
1+
---
2+
title: CodePipeline
3+
description: Run, monitor, and approve AWS CodePipeline pipelines
4+
---
5+
6+
import { BlockInfoCard } from "@/components/ui/block-info-card"
7+
8+
<BlockInfoCard
9+
type="codepipeline"
10+
color="linear-gradient(45deg, #2E27AD 0%, #527FFF 100%)"
11+
/>
12+
13+
## Usage Instructions
14+
15+
Integrate AWS CodePipeline into workflows. Start, stop, and monitor pipeline executions, retry failed stages, and approve or reject manual approval actions. Requires AWS access key and secret access key.
16+
17+
18+
19+
## Tools
20+
21+
### `codepipeline_list_pipelines`
22+
23+
List all CodePipeline pipelines in an AWS account and region
24+
25+
#### Input
26+
27+
| Parameter | Type | Required | Description |
28+
| --------- | ---- | -------- | ----------- |
29+
| `awsRegion` | string | Yes | AWS region \(e.g., us-east-1\) |
30+
| `awsAccessKeyId` | string | Yes | AWS access key ID |
31+
| `awsSecretAccessKey` | string | Yes | AWS secret access key |
32+
| `maxResults` | number | No | Maximum number of pipelines to return \(1-1000\) |
33+
| `nextToken` | string | No | Pagination token from a previous call |
34+
35+
#### Output
36+
37+
| Parameter | Type | Description |
38+
| --------- | ---- | ----------- |
39+
| `pipelines` | array | List of pipelines with name, version, type, and timestamps |
40+
|`name` | string | Pipeline name |
41+
|`version` | number | Pipeline version number |
42+
|`pipelineType` | string | Pipeline type \(V1 or V2\) |
43+
|`executionMode` | string | Execution mode \(QUEUED, SUPERSEDED, PARALLEL\) |
44+
|`created` | number | Epoch ms when the pipeline was created |
45+
|`updated` | number | Epoch ms when the pipeline was last updated |
46+
| `nextToken` | string | Pagination token for the next page of results |
47+
48+
### `codepipeline_get_pipeline_state`
49+
50+
Get the current state of a CodePipeline pipeline, including stage and action status and pending approval tokens
51+
52+
#### Input
53+
54+
| Parameter | Type | Required | Description |
55+
| --------- | ---- | -------- | ----------- |
56+
| `awsRegion` | string | Yes | AWS region \(e.g., us-east-1\) |
57+
| `awsAccessKeyId` | string | Yes | AWS access key ID |
58+
| `awsSecretAccessKey` | string | Yes | AWS secret access key |
59+
| `pipelineName` | string | Yes | Name of the pipeline |
60+
61+
#### Output
62+
63+
| Parameter | Type | Description |
64+
| --------- | ---- | ----------- |
65+
| `pipelineName` | string | Pipeline name |
66+
| `pipelineVersion` | number | Pipeline version number |
67+
| `created` | number | Epoch ms when the pipeline was created |
68+
| `updated` | number | Epoch ms when the pipeline was last updated |
69+
| `stageStates` | array | Per-stage state including latest execution status and action details |
70+
|`stageName` | string | Stage name |
71+
|`status` | string | Latest stage execution status \(InProgress, Succeeded, Failed, Stopped, Cancelled\) |
72+
|`pipelineExecutionId` | string | Pipeline execution ID currently in the stage |
73+
|`inboundTransitionEnabled` | boolean | Whether the inbound transition into the stage is enabled |
74+
|`actionStates` | array | Per-action state with status, summary, error details, and approval token \(for pending manual approvals\) |
75+
76+
### `codepipeline_get_pipeline_execution`
77+
78+
Get details of a CodePipeline execution, including status, trigger, source revisions, and resolved variables
79+
80+
#### Input
81+
82+
| Parameter | Type | Required | Description |
83+
| --------- | ---- | -------- | ----------- |
84+
| `awsRegion` | string | Yes | AWS region \(e.g., us-east-1\) |
85+
| `awsAccessKeyId` | string | Yes | AWS access key ID |
86+
| `awsSecretAccessKey` | string | Yes | AWS secret access key |
87+
| `pipelineName` | string | Yes | Name of the pipeline |
88+
| `pipelineExecutionId` | string | Yes | ID of the pipeline execution |
89+
90+
#### Output
91+
92+
| Parameter | Type | Description |
93+
| --------- | ---- | ----------- |
94+
| `pipelineExecutionId` | string | Pipeline execution ID |
95+
| `pipelineName` | string | Pipeline name |
96+
| `pipelineVersion` | number | Pipeline version number |
97+
| `status` | string | Execution status \(Cancelled, InProgress, Stopped, Stopping, Succeeded, Superseded, Failed\) |
98+
| `statusSummary` | string | Status summary for the execution |
99+
| `executionMode` | string | Execution mode \(QUEUED, SUPERSEDED, PARALLEL\) |
100+
| `executionType` | string | Execution type \(STANDARD or ROLLBACK\) |
101+
| `triggerType` | string | What triggered the execution \(e.g., Webhook, StartPipelineExecution\) |
102+
| `triggerDetail` | string | Detail about the trigger \(e.g., user ARN\) |
103+
| `artifactRevisions` | array | Source artifact revisions for the execution |
104+
|`name` | string | Artifact name |
105+
|`revisionId` | string | Revision ID \(e.g., commit SHA\) |
106+
|`revisionSummary` | string | Revision summary \(e.g., commit message\) |
107+
|`revisionUrl` | string | URL of the revision |
108+
|`created` | number | Epoch ms when the revision was created |
109+
| `variables` | array | Resolved pipeline variables for the execution |
110+
|`name` | string | Variable name |
111+
|`resolvedValue` | string | Resolved variable value |
112+
113+
### `codepipeline_list_pipeline_executions`
114+
115+
List recent executions of a CodePipeline pipeline with status and source revisions
116+
117+
#### Input
118+
119+
| Parameter | Type | Required | Description |
120+
| --------- | ---- | -------- | ----------- |
121+
| `awsRegion` | string | Yes | AWS region \(e.g., us-east-1\) |
122+
| `awsAccessKeyId` | string | Yes | AWS access key ID |
123+
| `awsSecretAccessKey` | string | Yes | AWS secret access key |
124+
| `pipelineName` | string | Yes | Name of the pipeline |
125+
| `maxResults` | number | No | Maximum number of executions to return \(1-100, default 100\) |
126+
| `nextToken` | string | No | Pagination token from a previous call |
127+
| `succeededInStage` | string | No | Only return executions that succeeded in this stage |
128+
129+
#### Output
130+
131+
| Parameter | Type | Description |
132+
| --------- | ---- | ----------- |
133+
| `executions` | array | Pipeline execution summaries, most recent first |
134+
|`pipelineExecutionId` | string | Pipeline execution ID |
135+
|`status` | string | Execution status \(Cancelled, InProgress, Stopped, Stopping, Succeeded, Superseded, Failed\) |
136+
|`statusSummary` | string | Status summary for the execution |
137+
|`startTime` | number | Epoch ms when the execution started |
138+
|`lastUpdateTime` | number | Epoch ms when the execution was last updated |
139+
|`executionMode` | string | Execution mode \(QUEUED, SUPERSEDED, PARALLEL\) |
140+
|`executionType` | string | Execution type \(STANDARD or ROLLBACK\) |
141+
|`stopTriggerReason` | string | Reason the execution was stopped, if applicable |
142+
|`triggerType` | string | What triggered the execution |
143+
|`triggerDetail` | string | Detail about the trigger |
144+
|`sourceRevisions` | array | Source revisions \(commit IDs, summaries, URLs\) for the execution |
145+
| `nextToken` | string | Pagination token for the next page of results |
146+
147+
### `codepipeline_start_execution`
148+
149+
Start a CodePipeline pipeline execution, optionally overriding pipeline variables
150+
151+
#### Input
152+
153+
| Parameter | Type | Required | Description |
154+
| --------- | ---- | -------- | ----------- |
155+
| `awsRegion` | string | Yes | AWS region \(e.g., us-east-1\) |
156+
| `awsAccessKeyId` | string | Yes | AWS access key ID |
157+
| `awsSecretAccessKey` | string | Yes | AWS secret access key |
158+
| `pipelineName` | string | Yes | Name of the pipeline to start |
159+
| `clientRequestToken` | string | No | Idempotency token to identify a unique execution request |
160+
| `variables` | json | No | Pipeline variable overrides as an array of \{ name, value \} objects |
161+
162+
#### Output
163+
164+
| Parameter | Type | Description |
165+
| --------- | ---- | ----------- |
166+
| `pipelineExecutionId` | string | ID of the pipeline execution that was started |
167+
168+
### `codepipeline_stop_execution`
169+
170+
Stop a CodePipeline pipeline execution, either finishing in-progress actions or abandoning them
171+
172+
#### Input
173+
174+
| Parameter | Type | Required | Description |
175+
| --------- | ---- | -------- | ----------- |
176+
| `awsRegion` | string | Yes | AWS region \(e.g., us-east-1\) |
177+
| `awsAccessKeyId` | string | Yes | AWS access key ID |
178+
| `awsSecretAccessKey` | string | Yes | AWS secret access key |
179+
| `pipelineName` | string | Yes | Name of the pipeline |
180+
| `pipelineExecutionId` | string | Yes | ID of the pipeline execution to stop |
181+
| `abandon` | boolean | No | Abandon in-progress actions instead of letting them finish \(default false\) |
182+
| `reason` | string | No | Reason for stopping the execution \(max 200 characters\) |
183+
184+
#### Output
185+
186+
| Parameter | Type | Description |
187+
| --------- | ---- | ----------- |
188+
| `pipelineExecutionId` | string | ID of the pipeline execution that was stopped |
189+
190+
### `codepipeline_retry_stage_execution`
191+
192+
Retry the failed actions (or all actions) of a failed CodePipeline stage
193+
194+
#### Input
195+
196+
| Parameter | Type | Required | Description |
197+
| --------- | ---- | -------- | ----------- |
198+
| `awsRegion` | string | Yes | AWS region \(e.g., us-east-1\) |
199+
| `awsAccessKeyId` | string | Yes | AWS access key ID |
200+
| `awsSecretAccessKey` | string | Yes | AWS secret access key |
201+
| `pipelineName` | string | Yes | Name of the pipeline |
202+
| `stageName` | string | Yes | Name of the failed stage to retry |
203+
| `pipelineExecutionId` | string | Yes | ID of the pipeline execution in the failed stage |
204+
| `retryMode` | string | Yes | Scope of the retry: FAILED_ACTIONS or ALL_ACTIONS |
205+
206+
#### Output
207+
208+
| Parameter | Type | Description |
209+
| --------- | ---- | ----------- |
210+
| `pipelineExecutionId` | string | ID of the pipeline execution with the retried stage |
211+
212+
### `codepipeline_put_approval_result`
213+
214+
Approve or reject a pending CodePipeline manual approval action. The approval token is available from Get Pipeline State on the pending approval action
215+
216+
#### Input
217+
218+
| Parameter | Type | Required | Description |
219+
| --------- | ---- | -------- | ----------- |
220+
| `awsRegion` | string | Yes | AWS region \(e.g., us-east-1\) |
221+
| `awsAccessKeyId` | string | Yes | AWS access key ID |
222+
| `awsSecretAccessKey` | string | Yes | AWS secret access key |
223+
| `pipelineName` | string | Yes | Name of the pipeline |
224+
| `stageName` | string | Yes | Name of the stage containing the approval action |
225+
| `actionName` | string | Yes | Name of the manual approval action |
226+
| `token` | string | Yes | Approval token from Get Pipeline State for the pending approval |
227+
| `status` | string | Yes | Approval decision: Approved or Rejected |
228+
| `summary` | string | Yes | Summary explaining the approval decision \(max 512 characters\) |
229+
230+
#### Output
231+
232+
| Parameter | Type | Description |
233+
| --------- | ---- | ----------- |
234+
| `approvedAt` | number | Epoch ms when the approval or rejection was submitted |
235+
| `status` | string | The submitted approval decision \(Approved or Rejected\) |
236+
237+

apps/docs/content/docs/en/tools/meta.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"cloudflare",
3030
"cloudformation",
3131
"cloudwatch",
32+
"codepipeline",
3233
"confluence",
3334
"crowdstrike",
3435
"cursor",
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import { CodePipelineClient, GetPipelineExecutionCommand } from '@aws-sdk/client-codepipeline'
2+
import { createLogger } from '@sim/logger'
3+
import { toError } from '@sim/utils/errors'
4+
import { type NextRequest, NextResponse } from 'next/server'
5+
import { awsCodepipelineGetPipelineExecutionContract } from '@/lib/api/contracts/tools/aws/codepipeline-get-pipeline-execution'
6+
import { parseToolRequest } from '@/lib/api/server'
7+
import { checkInternalAuth } from '@/lib/auth/hybrid'
8+
import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
9+
10+
const logger = createLogger('CodePipelineGetPipelineExecution')
11+
12+
export const POST = withRouteHandler(async (request: NextRequest) => {
13+
try {
14+
const auth = await checkInternalAuth(request)
15+
if (!auth.success || !auth.userId) {
16+
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
17+
}
18+
19+
const parsed = await parseToolRequest(awsCodepipelineGetPipelineExecutionContract, request, {
20+
errorFormat: 'details',
21+
logger,
22+
})
23+
if (!parsed.success) return parsed.response
24+
const validatedData = parsed.data.body
25+
26+
logger.info('Getting CodePipeline pipeline execution')
27+
28+
const client = new CodePipelineClient({
29+
region: validatedData.region,
30+
credentials: {
31+
accessKeyId: validatedData.accessKeyId,
32+
secretAccessKey: validatedData.secretAccessKey,
33+
},
34+
})
35+
36+
try {
37+
const command = new GetPipelineExecutionCommand({
38+
pipelineName: validatedData.pipelineName,
39+
pipelineExecutionId: validatedData.pipelineExecutionId,
40+
})
41+
42+
const response = await client.send(command)
43+
const execution = response.pipelineExecution
44+
45+
if (!execution) {
46+
throw new Error('Pipeline execution not found in response')
47+
}
48+
49+
logger.info('Successfully got pipeline execution')
50+
51+
return NextResponse.json({
52+
success: true,
53+
output: {
54+
pipelineExecutionId: execution.pipelineExecutionId ?? validatedData.pipelineExecutionId,
55+
pipelineName: execution.pipelineName ?? validatedData.pipelineName,
56+
pipelineVersion: execution.pipelineVersion,
57+
status: execution.status ?? 'Unknown',
58+
statusSummary: execution.statusSummary,
59+
executionMode: execution.executionMode,
60+
executionType: execution.executionType,
61+
triggerType: execution.trigger?.triggerType,
62+
triggerDetail: execution.trigger?.triggerDetail,
63+
artifactRevisions: (execution.artifactRevisions ?? []).map((r) => ({
64+
name: r.name ?? '',
65+
revisionId: r.revisionId,
66+
revisionSummary: r.revisionSummary,
67+
revisionUrl: r.revisionUrl,
68+
created: r.created?.getTime(),
69+
})),
70+
variables: (execution.variables ?? []).map((v) => ({
71+
name: v.name ?? '',
72+
resolvedValue: v.resolvedValue ?? '',
73+
})),
74+
},
75+
})
76+
} finally {
77+
client.destroy()
78+
}
79+
} catch (error) {
80+
logger.error('GetPipelineExecution failed', { error: toError(error).message })
81+
return NextResponse.json(
82+
{ error: `Failed to get CodePipeline pipeline execution: ${toError(error).message}` },
83+
{ status: 500 }
84+
)
85+
}
86+
})

0 commit comments

Comments
 (0)