Skip to content

Commit 27a9b33

Browse files
author
awstools
committed
feat(client-codepipeline): Add ability to manually and automatically roll back a pipeline stage to a previously successful execution.
1 parent 231317d commit 27a9b33

14 files changed

+726
-2
lines changed

Diff for: clients/client-codepipeline/README.md

+8
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,14 @@ RetryStageExecution
660660

661661
[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/codepipeline/command/RetryStageExecutionCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-codepipeline/Interface/RetryStageExecutionCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-codepipeline/Interface/RetryStageExecutionCommandOutput/)
662662

663+
</details>
664+
<details>
665+
<summary>
666+
RollbackStage
667+
</summary>
668+
669+
[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/codepipeline/command/RollbackStageCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-codepipeline/Interface/RollbackStageCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-codepipeline/Interface/RollbackStageCommandOutput/)
670+
663671
</details>
664672
<details>
665673
<summary>

Diff for: clients/client-codepipeline/src/CodePipeline.ts

+17
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,11 @@ import {
156156
RetryStageExecutionCommandInput,
157157
RetryStageExecutionCommandOutput,
158158
} from "./commands/RetryStageExecutionCommand";
159+
import {
160+
RollbackStageCommand,
161+
RollbackStageCommandInput,
162+
RollbackStageCommandOutput,
163+
} from "./commands/RollbackStageCommand";
159164
import {
160165
StartPipelineExecutionCommand,
161166
StartPipelineExecutionCommandInput,
@@ -217,6 +222,7 @@ const commands = {
217222
PutWebhookCommand,
218223
RegisterWebhookWithThirdPartyCommand,
219224
RetryStageExecutionCommand,
225+
RollbackStageCommand,
220226
StartPipelineExecutionCommand,
221227
StopPipelineExecutionCommand,
222228
TagResourceCommand,
@@ -732,6 +738,17 @@ export interface CodePipeline {
732738
cb: (err: any, data?: RetryStageExecutionCommandOutput) => void
733739
): void;
734740

741+
/**
742+
* @see {@link RollbackStageCommand}
743+
*/
744+
rollbackStage(args: RollbackStageCommandInput, options?: __HttpHandlerOptions): Promise<RollbackStageCommandOutput>;
745+
rollbackStage(args: RollbackStageCommandInput, cb: (err: any, data?: RollbackStageCommandOutput) => void): void;
746+
rollbackStage(
747+
args: RollbackStageCommandInput,
748+
options: __HttpHandlerOptions,
749+
cb: (err: any, data?: RollbackStageCommandOutput) => void
750+
): void;
751+
735752
/**
736753
* @see {@link StartPipelineExecutionCommand}
737754
*/

Diff for: clients/client-codepipeline/src/CodePipelineClient.ts

+3
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ import {
140140
RetryStageExecutionCommandInput,
141141
RetryStageExecutionCommandOutput,
142142
} from "./commands/RetryStageExecutionCommand";
143+
import { RollbackStageCommandInput, RollbackStageCommandOutput } from "./commands/RollbackStageCommand";
143144
import {
144145
StartPipelineExecutionCommandInput,
145146
StartPipelineExecutionCommandOutput,
@@ -200,6 +201,7 @@ export type ServiceInputTypes =
200201
| PutWebhookCommandInput
201202
| RegisterWebhookWithThirdPartyCommandInput
202203
| RetryStageExecutionCommandInput
204+
| RollbackStageCommandInput
203205
| StartPipelineExecutionCommandInput
204206
| StopPipelineExecutionCommandInput
205207
| TagResourceCommandInput
@@ -244,6 +246,7 @@ export type ServiceOutputTypes =
244246
| PutWebhookCommandOutput
245247
| RegisterWebhookWithThirdPartyCommandOutput
246248
| RetryStageExecutionCommandOutput
249+
| RollbackStageCommandOutput
247250
| StartPipelineExecutionCommandOutput
248251
| StopPipelineExecutionCommandOutput
249252
| TagResourceCommandOutput

Diff for: clients/client-codepipeline/src/commands/CreatePipelineCommand.ts

+6
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ export interface CreatePipelineCommandOutput extends CreatePipelineOutput, __Met
100100
* timeoutInMinutes: Number("int"),
101101
* },
102102
* ],
103+
* onFailure: { // FailureConditions
104+
* result: "ROLLBACK",
105+
* },
103106
* },
104107
* ],
105108
* version: Number("int"),
@@ -241,6 +244,9 @@ export interface CreatePipelineCommandOutput extends CreatePipelineOutput, __Met
241244
* // timeoutInMinutes: Number("int"),
242245
* // },
243246
* // ],
247+
* // onFailure: { // FailureConditions
248+
* // result: "ROLLBACK",
249+
* // },
244250
* // },
245251
* // ],
246252
* // version: Number("int"),

Diff for: clients/client-codepipeline/src/commands/GetPipelineCommand.ts

+3
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ export interface GetPipelineCommandOutput extends GetPipelineOutput, __MetadataB
102102
* // timeoutInMinutes: Number("int"),
103103
* // },
104104
* // ],
105+
* // onFailure: { // FailureConditions
106+
* // result: "ROLLBACK",
107+
* // },
105108
* // },
106109
* // ],
107110
* // version: Number("int"),

Diff for: clients/client-codepipeline/src/commands/GetPipelineExecutionCommand.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,14 @@ export interface GetPipelineExecutionCommandOutput extends GetPipelineExecutionO
6666
* // },
6767
* // ],
6868
* // trigger: { // ExecutionTrigger
69-
* // triggerType: "CreatePipeline" || "StartPipelineExecution" || "PollForSourceChanges" || "Webhook" || "CloudWatchEvent" || "PutActionRevision" || "WebhookV2",
69+
* // triggerType: "CreatePipeline" || "StartPipelineExecution" || "PollForSourceChanges" || "Webhook" || "CloudWatchEvent" || "PutActionRevision" || "WebhookV2" || "ManualRollback" || "AutomatedRollback",
7070
* // triggerDetail: "STRING_VALUE",
7171
* // },
7272
* // executionMode: "QUEUED" || "SUPERSEDED" || "PARALLEL",
73+
* // executionType: "STANDARD" || "ROLLBACK",
74+
* // rollbackMetadata: { // PipelineRollbackMetadata
75+
* // rollbackTargetPipelineExecutionId: "STRING_VALUE",
76+
* // },
7377
* // },
7478
* // };
7579
*

Diff for: clients/client-codepipeline/src/commands/GetPipelineStateCommand.ts

+3
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,13 @@ export interface GetPipelineStateCommandOutput extends GetPipelineStateOutput, _
5454
* // inboundExecution: { // StageExecution
5555
* // pipelineExecutionId: "STRING_VALUE", // required
5656
* // status: "Cancelled" || "InProgress" || "Failed" || "Stopped" || "Stopping" || "Succeeded", // required
57+
* // type: "STANDARD" || "ROLLBACK",
5758
* // },
5859
* // inboundExecutions: [ // StageExecutionList
5960
* // {
6061
* // pipelineExecutionId: "STRING_VALUE", // required
6162
* // status: "Cancelled" || "InProgress" || "Failed" || "Stopped" || "Stopping" || "Succeeded", // required
63+
* // type: "STANDARD" || "ROLLBACK",
6264
* // },
6365
* // ],
6466
* // inboundTransitionState: { // TransitionState
@@ -97,6 +99,7 @@ export interface GetPipelineStateCommandOutput extends GetPipelineStateOutput, _
9799
* // latestExecution: {
98100
* // pipelineExecutionId: "STRING_VALUE", // required
99101
* // status: "Cancelled" || "InProgress" || "Failed" || "Stopped" || "Stopping" || "Succeeded", // required
102+
* // type: "STANDARD" || "ROLLBACK",
100103
* // },
101104
* // },
102105
* // ],

Diff for: clients/client-codepipeline/src/commands/ListPipelineExecutionsCommand.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ export interface ListPipelineExecutionsCommandOutput extends ListPipelineExecuti
3737
* const input = { // ListPipelineExecutionsInput
3838
* pipelineName: "STRING_VALUE", // required
3939
* maxResults: Number("int"),
40+
* filter: { // PipelineExecutionFilter
41+
* succeededInStage: { // SucceededInStageFilter
42+
* stageName: "STRING_VALUE",
43+
* },
44+
* },
4045
* nextToken: "STRING_VALUE",
4146
* };
4247
* const command = new ListPipelineExecutionsCommand(input);
@@ -46,6 +51,7 @@ export interface ListPipelineExecutionsCommandOutput extends ListPipelineExecuti
4651
* // { // PipelineExecutionSummary
4752
* // pipelineExecutionId: "STRING_VALUE",
4853
* // status: "Cancelled" || "InProgress" || "Stopped" || "Stopping" || "Succeeded" || "Superseded" || "Failed",
54+
* // statusSummary: "STRING_VALUE",
4955
* // startTime: new Date("TIMESTAMP"),
5056
* // lastUpdateTime: new Date("TIMESTAMP"),
5157
* // sourceRevisions: [ // SourceRevisionList
@@ -57,13 +63,17 @@ export interface ListPipelineExecutionsCommandOutput extends ListPipelineExecuti
5763
* // },
5864
* // ],
5965
* // trigger: { // ExecutionTrigger
60-
* // triggerType: "CreatePipeline" || "StartPipelineExecution" || "PollForSourceChanges" || "Webhook" || "CloudWatchEvent" || "PutActionRevision" || "WebhookV2",
66+
* // triggerType: "CreatePipeline" || "StartPipelineExecution" || "PollForSourceChanges" || "Webhook" || "CloudWatchEvent" || "PutActionRevision" || "WebhookV2" || "ManualRollback" || "AutomatedRollback",
6167
* // triggerDetail: "STRING_VALUE",
6268
* // },
6369
* // stopTrigger: { // StopExecutionTrigger
6470
* // reason: "STRING_VALUE",
6571
* // },
6672
* // executionMode: "QUEUED" || "SUPERSEDED" || "PARALLEL",
73+
* // executionType: "STANDARD" || "ROLLBACK",
74+
* // rollbackMetadata: { // PipelineRollbackMetadata
75+
* // rollbackTargetPipelineExecutionId: "STRING_VALUE",
76+
* // },
6777
* // },
6878
* // ],
6979
* // nextToken: "STRING_VALUE",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
// smithy-typescript generated code
2+
import { getEndpointPlugin } from "@smithy/middleware-endpoint";
3+
import { getSerdePlugin } from "@smithy/middleware-serde";
4+
import { Command as $Command } from "@smithy/smithy-client";
5+
import { MetadataBearer as __MetadataBearer } from "@smithy/types";
6+
7+
import { CodePipelineClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../CodePipelineClient";
8+
import { commonParams } from "../endpoint/EndpointParameters";
9+
import { RollbackStageInput, RollbackStageOutput } from "../models/models_0";
10+
import { de_RollbackStageCommand, se_RollbackStageCommand } from "../protocols/Aws_json1_1";
11+
12+
/**
13+
* @public
14+
*/
15+
export { __MetadataBearer, $Command };
16+
/**
17+
* @public
18+
*
19+
* The input for {@link RollbackStageCommand}.
20+
*/
21+
export interface RollbackStageCommandInput extends RollbackStageInput {}
22+
/**
23+
* @public
24+
*
25+
* The output of {@link RollbackStageCommand}.
26+
*/
27+
export interface RollbackStageCommandOutput extends RollbackStageOutput, __MetadataBearer {}
28+
29+
/**
30+
* <p>Rolls back a stage execution.</p>
31+
* @example
32+
* Use a bare-bones client and the command you need to make an API call.
33+
* ```javascript
34+
* import { CodePipelineClient, RollbackStageCommand } from "@aws-sdk/client-codepipeline"; // ES Modules import
35+
* // const { CodePipelineClient, RollbackStageCommand } = require("@aws-sdk/client-codepipeline"); // CommonJS import
36+
* const client = new CodePipelineClient(config);
37+
* const input = { // RollbackStageInput
38+
* pipelineName: "STRING_VALUE", // required
39+
* stageName: "STRING_VALUE", // required
40+
* targetPipelineExecutionId: "STRING_VALUE", // required
41+
* };
42+
* const command = new RollbackStageCommand(input);
43+
* const response = await client.send(command);
44+
* // { // RollbackStageOutput
45+
* // pipelineExecutionId: "STRING_VALUE", // required
46+
* // };
47+
*
48+
* ```
49+
*
50+
* @param RollbackStageCommandInput - {@link RollbackStageCommandInput}
51+
* @returns {@link RollbackStageCommandOutput}
52+
* @see {@link RollbackStageCommandInput} for command's `input` shape.
53+
* @see {@link RollbackStageCommandOutput} for command's `response` shape.
54+
* @see {@link CodePipelineClientResolvedConfig | config} for CodePipelineClient's `config` shape.
55+
*
56+
* @throws {@link ConflictException} (client fault)
57+
* <p>Your request cannot be handled because the pipeline is busy handling ongoing
58+
* activities. Try again later.</p>
59+
*
60+
* @throws {@link PipelineExecutionNotFoundException} (client fault)
61+
* <p>The pipeline execution was specified in an invalid format or cannot be found, or an
62+
* execution ID does not belong to the specified pipeline. </p>
63+
*
64+
* @throws {@link PipelineExecutionOutdatedException} (client fault)
65+
* <p>The specified pipeline execution is outdated and cannot be used as a target pipeline execution for rollback.</p>
66+
*
67+
* @throws {@link PipelineNotFoundException} (client fault)
68+
* <p>The pipeline was specified in an invalid format or cannot be found.</p>
69+
*
70+
* @throws {@link StageNotFoundException} (client fault)
71+
* <p>The stage was specified in an invalid format or cannot be found.</p>
72+
*
73+
* @throws {@link UnableToRollbackStageException} (client fault)
74+
* <p>Unable to roll back the stage. The cause might be if the pipeline version has changed
75+
* since the target pipeline execution was deployed, the stage is currently running, or an
76+
* incorrect target pipeline execution ID was provided.</p>
77+
*
78+
* @throws {@link ValidationException} (client fault)
79+
* <p>The validation was specified in an invalid format.</p>
80+
*
81+
* @throws {@link CodePipelineServiceException}
82+
* <p>Base exception class for all service exceptions from CodePipeline service.</p>
83+
*
84+
* @public
85+
*/
86+
export class RollbackStageCommand extends $Command
87+
.classBuilder<
88+
RollbackStageCommandInput,
89+
RollbackStageCommandOutput,
90+
CodePipelineClientResolvedConfig,
91+
ServiceInputTypes,
92+
ServiceOutputTypes
93+
>()
94+
.ep({
95+
...commonParams,
96+
})
97+
.m(function (this: any, Command: any, cs: any, config: CodePipelineClientResolvedConfig, o: any) {
98+
return [
99+
getSerdePlugin(config, this.serialize, this.deserialize),
100+
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
101+
];
102+
})
103+
.s("CodePipeline_20150709", "RollbackStage", {})
104+
.n("CodePipelineClient", "RollbackStageCommand")
105+
.f(void 0, void 0)
106+
.ser(se_RollbackStageCommand)
107+
.de(de_RollbackStageCommand)
108+
.build() {}

Diff for: clients/client-codepipeline/src/commands/UpdatePipelineCommand.ts

+6
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ export interface UpdatePipelineCommandOutput extends UpdatePipelineOutput, __Met
9797
* timeoutInMinutes: Number("int"),
9898
* },
9999
* ],
100+
* onFailure: { // FailureConditions
101+
* result: "ROLLBACK",
102+
* },
100103
* },
101104
* ],
102105
* version: Number("int"),
@@ -232,6 +235,9 @@ export interface UpdatePipelineCommandOutput extends UpdatePipelineOutput, __Met
232235
* // timeoutInMinutes: Number("int"),
233236
* // },
234237
* // ],
238+
* // onFailure: { // FailureConditions
239+
* // result: "ROLLBACK",
240+
* // },
235241
* // },
236242
* // ],
237243
* // version: Number("int"),

Diff for: clients/client-codepipeline/src/commands/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export * from "./PutThirdPartyJobSuccessResultCommand";
3232
export * from "./PutWebhookCommand";
3333
export * from "./RegisterWebhookWithThirdPartyCommand";
3434
export * from "./RetryStageExecutionCommand";
35+
export * from "./RollbackStageCommand";
3536
export * from "./StartPipelineExecutionCommand";
3637
export * from "./StopPipelineExecutionCommand";
3738
export * from "./TagResourceCommand";

0 commit comments

Comments
 (0)