Rolls back a stage execution.
+ * @example + * Use a bare-bones client and the command you need to make an API call. + * ```javascript + * import { CodePipelineClient, RollbackStageCommand } from "@aws-sdk/client-codepipeline"; // ES Modules import + * // const { CodePipelineClient, RollbackStageCommand } = require("@aws-sdk/client-codepipeline"); // CommonJS import + * const client = new CodePipelineClient(config); + * const input = { // RollbackStageInput + * pipelineName: "STRING_VALUE", // required + * stageName: "STRING_VALUE", // required + * targetPipelineExecutionId: "STRING_VALUE", // required + * }; + * const command = new RollbackStageCommand(input); + * const response = await client.send(command); + * // { // RollbackStageOutput + * // pipelineExecutionId: "STRING_VALUE", // required + * // }; + * + * ``` + * + * @param RollbackStageCommandInput - {@link RollbackStageCommandInput} + * @returns {@link RollbackStageCommandOutput} + * @see {@link RollbackStageCommandInput} for command's `input` shape. + * @see {@link RollbackStageCommandOutput} for command's `response` shape. + * @see {@link CodePipelineClientResolvedConfig | config} for CodePipelineClient's `config` shape. + * + * @throws {@link ConflictException} (client fault) + *Your request cannot be handled because the pipeline is busy handling ongoing + * activities. Try again later.
+ * + * @throws {@link PipelineExecutionNotFoundException} (client fault) + *The pipeline execution was specified in an invalid format or cannot be found, or an + * execution ID does not belong to the specified pipeline.
+ * + * @throws {@link PipelineExecutionOutdatedException} (client fault) + *The specified pipeline execution is outdated and cannot be used as a target pipeline execution for rollback.
+ * + * @throws {@link PipelineNotFoundException} (client fault) + *The pipeline was specified in an invalid format or cannot be found.
+ * + * @throws {@link StageNotFoundException} (client fault) + *The stage was specified in an invalid format or cannot be found.
+ * + * @throws {@link UnableToRollbackStageException} (client fault) + *Unable to roll back the stage. The cause might be if the pipeline version has changed + * since the target pipeline execution was deployed, the stage is currently running, or an + * incorrect target pipeline execution ID was provided.
+ * + * @throws {@link ValidationException} (client fault) + *The validation was specified in an invalid format.
+ * + * @throws {@link CodePipelineServiceException} + *Base exception class for all service exceptions from CodePipeline service.
+ * + * @public + */ +export class RollbackStageCommand extends $Command + .classBuilder< + RollbackStageCommandInput, + RollbackStageCommandOutput, + CodePipelineClientResolvedConfig, + ServiceInputTypes, + ServiceOutputTypes + >() + .ep({ + ...commonParams, + }) + .m(function (this: any, Command: any, cs: any, config: CodePipelineClientResolvedConfig, o: any) { + return [ + getSerdePlugin(config, this.serialize, this.deserialize), + getEndpointPlugin(config, Command.getEndpointParameterInstructions()), + ]; + }) + .s("CodePipeline_20150709", "RollbackStage", {}) + .n("CodePipelineClient", "RollbackStageCommand") + .f(void 0, void 0) + .ser(se_RollbackStageCommand) + .de(de_RollbackStageCommand) + .build() {} diff --git a/clients/client-codepipeline/src/commands/UpdatePipelineCommand.ts b/clients/client-codepipeline/src/commands/UpdatePipelineCommand.ts index 01c41eb21b39..aacd466a62ee 100644 --- a/clients/client-codepipeline/src/commands/UpdatePipelineCommand.ts +++ b/clients/client-codepipeline/src/commands/UpdatePipelineCommand.ts @@ -97,6 +97,9 @@ export interface UpdatePipelineCommandOutput extends UpdatePipelineOutput, __Met * timeoutInMinutes: Number("int"), * }, * ], + * onFailure: { // FailureConditions + * result: "ROLLBACK", + * }, * }, * ], * version: Number("int"), @@ -232,6 +235,9 @@ export interface UpdatePipelineCommandOutput extends UpdatePipelineOutput, __Met * // timeoutInMinutes: Number("int"), * // }, * // ], + * // onFailure: { // FailureConditions + * // result: "ROLLBACK", + * // }, * // }, * // ], * // version: Number("int"), diff --git a/clients/client-codepipeline/src/commands/index.ts b/clients/client-codepipeline/src/commands/index.ts index 16ee896ff1d4..90b51e1559a3 100644 --- a/clients/client-codepipeline/src/commands/index.ts +++ b/clients/client-codepipeline/src/commands/index.ts @@ -32,6 +32,7 @@ export * from "./PutThirdPartyJobSuccessResultCommand"; export * from "./PutWebhookCommand"; export * from "./RegisterWebhookWithThirdPartyCommand"; export * from "./RetryStageExecutionCommand"; +export * from "./RollbackStageCommand"; export * from "./StartPipelineExecutionCommand"; export * from "./StopPipelineExecutionCommand"; export * from "./TagResourceCommand"; diff --git a/clients/client-codepipeline/src/models/models_0.ts b/clients/client-codepipeline/src/models/models_0.ts index 55b07654c6a3..8e7ff2997d69 100644 --- a/clients/client-codepipeline/src/models/models_0.ts +++ b/clients/client-codepipeline/src/models/models_0.ts @@ -1985,6 +1985,31 @@ export const PipelineType = { */ export type PipelineType = (typeof PipelineType)[keyof typeof PipelineType]; +/** + * @public + * @enum + */ +export const Result = { + ROLLBACK: "ROLLBACK", +} as const; + +/** + * @public + */ +export type Result = (typeof Result)[keyof typeof Result]; + +/** + *The configuration that specifies the result, such as rollback, to occur upon stage failure.
+ * @public + */ +export interface FailureConditions { + /** + *The specified result for when the failure conditions are met, such as rolling back the stage.
+ * @public + */ + result?: Result; +} + /** *Represents information about a stage and its definition.
* @public @@ -2007,6 +2032,12 @@ export interface StageDeclaration { * @public */ actions: ActionDeclaration[] | undefined; + + /** + *The method to use when a stage has not completed successfully. For example, configuring this field for rollback will roll back a failed stage automatically to the last successful pipeline execution in the stage.
+ * @public + */ + onFailure?: FailureConditions; } /** @@ -3073,6 +3104,32 @@ export interface GetPipelineExecutionInput { pipelineExecutionId: string | undefined; } +/** + * @public + * @enum + */ +export const ExecutionType = { + ROLLBACK: "ROLLBACK", + STANDARD: "STANDARD", +} as const; + +/** + * @public + */ +export type ExecutionType = (typeof ExecutionType)[keyof typeof ExecutionType]; + +/** + *The metadata for the stage execution to be rolled back.
+ * @public + */ +export interface PipelineRollbackMetadata { + /** + *The pipeline execution ID to which the stage will be rolled back.
+ * @public + */ + rollbackTargetPipelineExecutionId?: string; +} + /** * @public * @enum @@ -3097,8 +3154,10 @@ export type PipelineExecutionStatus = (typeof PipelineExecutionStatus)[keyof typ * @enum */ export const TriggerType = { + AutomatedRollback: "AutomatedRollback", CloudWatchEvent: "CloudWatchEvent", CreatePipeline: "CreatePipeline", + ManualRollback: "ManualRollback", PollForSourceChanges: "PollForSourceChanges", PutActionRevision: "PutActionRevision", StartPipelineExecution: "StartPipelineExecution", @@ -3239,6 +3298,18 @@ export interface PipelineExecution { * @public */ executionMode?: ExecutionMode; + + /** + *The type of the pipeline execution.
+ * @public + */ + executionType?: ExecutionType; + + /** + *The metadata about the execution pertaining to stage rollback.
+ * @public + */ + rollbackMetadata?: PipelineRollbackMetadata; } /** @@ -3325,6 +3396,12 @@ export interface StageExecution { * @public */ status: StageExecutionStatus | undefined; + + /** + *The type of pipeline execution for the stage, such as a rollback pipeline execution.
+ * @public + */ + type?: ExecutionType; } /** @@ -3713,6 +3790,32 @@ export interface ListActionTypesOutput { nextToken?: string; } +/** + *Filter for pipeline executions that have successfully completed the stage in the current pipeline version.
+ * @public + */ +export interface SucceededInStageFilter { + /** + *The name of the stage for filtering for pipeline executions where the stage was successful in the current pipeline + * version.
+ * @public + */ + stageName?: string; +} + +/** + *The pipeline execution to filter on.
+ * @public + */ +export interface PipelineExecutionFilter { + /** + *Filter for pipeline executions where the stage was successful in the current pipeline + * version.
+ * @public + */ + succeededInStage?: SucceededInStageFilter; +} + /** *Represents the input of a ListPipelineExecutions
action.
The pipeline execution to filter on.
+ * @public + */ + filter?: PipelineExecutionFilter; + /** *The token that was returned from the previous ListPipelineExecutions
* call, which can be used to return the next set of pipeline executions in the
@@ -3834,6 +3943,12 @@ export interface PipelineExecutionSummary {
*/
status?: PipelineExecutionStatus;
+ /**
+ *
Status summary for the pipeline.
+ * @public + */ + statusSummary?: string; + /** *The date and time when the pipeline execution began, in timestamp format.
* @public @@ -3873,6 +3988,18 @@ export interface PipelineExecutionSummary { * @public */ executionMode?: ExecutionMode; + + /** + *Type of the pipeline execution.
+ * @public + */ + executionType?: ExecutionType; + + /** + *The metadata for the stage execution to be rolled back.
+ * @public + */ + rollbackMetadata?: PipelineRollbackMetadata; } /** @@ -5035,6 +5162,83 @@ export class StageNotRetryableException extends __BaseException { } } +/** + *The specified pipeline execution is outdated and cannot be used as a target pipeline execution for rollback.
+ * @public + */ +export class PipelineExecutionOutdatedException extends __BaseException { + readonly name: "PipelineExecutionOutdatedException" = "PipelineExecutionOutdatedException"; + readonly $fault: "client" = "client"; + /** + * @internal + */ + constructor(opts: __ExceptionOptionTypeThe name of the pipeline for which the stage will be rolled back.
+ * @public + */ + pipelineName: string | undefined; + + /** + *The name of the stage in the pipeline to be rolled back.
+ * @public + */ + stageName: string | undefined; + + /** + *The pipeline execution ID for the stage to be rolled back to.
+ * @public + */ + targetPipelineExecutionId: string | undefined; +} + +/** + * @public + */ +export interface RollbackStageOutput { + /** + *The execution ID of the pipeline execution for the stage that has been rolled + * back.
+ * @public + */ + pipelineExecutionId: string | undefined; +} + +/** + *Unable to roll back the stage. The cause might be if the pipeline version has changed + * since the target pipeline execution was deployed, the stage is currently running, or an + * incorrect target pipeline execution ID was provided.
+ * @public + */ +export class UnableToRollbackStageException extends __BaseException { + readonly name: "UnableToRollbackStageException" = "UnableToRollbackStageException"; + readonly $fault: "client" = "client"; + /** + * @internal + */ + constructor(opts: __ExceptionOptionTypeThe pipeline has reached the limit for concurrent pipeline executions.
* @public diff --git a/clients/client-codepipeline/src/protocols/Aws_json1_1.ts b/clients/client-codepipeline/src/protocols/Aws_json1_1.ts index 5104bf66c6c0..402b83d6a2d1 100644 --- a/clients/client-codepipeline/src/protocols/Aws_json1_1.ts +++ b/clients/client-codepipeline/src/protocols/Aws_json1_1.ts @@ -109,6 +109,7 @@ import { RetryStageExecutionCommandInput, RetryStageExecutionCommandOutput, } from "../commands/RetryStageExecutionCommand"; +import { RollbackStageCommandInput, RollbackStageCommandOutput } from "../commands/RollbackStageCommand"; import { StartPipelineExecutionCommandInput, StartPipelineExecutionCommandOutput, @@ -165,6 +166,7 @@ import { EncryptionKey, ExecutionDetails, ExecutorConfiguration, + FailureConditions, FailureDetails, GetActionTypeInput, GetJobDetailsInput, @@ -218,8 +220,10 @@ import { OutputVariablesSizeExceededException, PipelineDeclaration, PipelineExecution, + PipelineExecutionFilter, PipelineExecutionNotFoundException, PipelineExecutionNotStoppableException, + PipelineExecutionOutdatedException, PipelineExecutionSummary, PipelineMetadata, PipelineNameInUseException, @@ -244,6 +248,7 @@ import { RequestFailedException, ResourceNotFoundException, RetryStageExecutionInput, + RollbackStageInput, SourceRevisionOverride, StageDeclaration, StageNotFoundException, @@ -251,10 +256,12 @@ import { StageState, StartPipelineExecutionInput, StopPipelineExecutionInput, + SucceededInStageFilter, Tag, TagResourceInput, TooManyTagsException, TransitionState, + UnableToRollbackStageException, UntagResourceInput, UpdateActionTypeInput, UpdatePipelineInput, @@ -694,6 +701,19 @@ export const se_RetryStageExecutionCommand = async ( return buildHttpRpcRequest(context, headers, "/", undefined, body); }; +/** + * serializeAws_json1_1RollbackStageCommand + */ +export const se_RollbackStageCommand = async ( + input: RollbackStageCommandInput, + context: __SerdeContext +): Promise<__HttpRequest> => { + const headers: __HeaderBag = sharedHeaders("RollbackStage"); + let body: any; + body = JSON.stringify(_json(input)); + return buildHttpRpcRequest(context, headers, "/", undefined, body); +}; + /** * serializeAws_json1_1StartPipelineExecutionCommand */ @@ -1408,6 +1428,26 @@ export const de_RetryStageExecutionCommand = async ( return response; }; +/** + * deserializeAws_json1_1RollbackStageCommand + */ +export const de_RollbackStageCommand = async ( + output: __HttpResponse, + context: __SerdeContext +): PromiseThe interaction or event that started a pipeline execution.
" } }, + "com.amazonaws.codepipeline#ExecutionType": { + "type": "enum", + "members": { + "STANDARD": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "STANDARD" + } + }, + "ROLLBACK": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "ROLLBACK" + } + } + } + }, "com.amazonaws.codepipeline#ExecutorConfiguration": { "type": "structure", "members": { @@ -3627,6 +3647,20 @@ "com.amazonaws.codepipeline#ExternalExecutionSummary": { "type": "string" }, + "com.amazonaws.codepipeline#FailureConditions": { + "type": "structure", + "members": { + "result": { + "target": "com.amazonaws.codepipeline#Result", + "traits": { + "smithy.api#documentation": "The specified result for when the failure conditions are met, such as rolling back the stage.
" + } + } + }, + "traits": { + "smithy.api#documentation": "The configuration that specifies the result, such as rollback, to occur upon stage failure.
" + } + }, "com.amazonaws.codepipeline#FailureDetails": { "type": "structure", "members": { @@ -5072,6 +5106,12 @@ "smithy.api#documentation": "The maximum number of results to return in a single call. To retrieve the remaining\n results, make another call with the returned nextToken value. Pipeline history is\n limited to the most recent 12 months, based on pipeline execution start times. Default\n value is 100.
" } }, + "filter": { + "target": "com.amazonaws.codepipeline#PipelineExecutionFilter", + "traits": { + "smithy.api#documentation": "The pipeline execution to filter on.
" + } + }, "nextToken": { "target": "com.amazonaws.codepipeline#NextToken", "traits": { @@ -5715,12 +5755,38 @@ "traits": { "smithy.api#documentation": "The method that the pipeline will use to handle multiple executions. The default\n mode is SUPERSEDED.
" } + }, + "executionType": { + "target": "com.amazonaws.codepipeline#ExecutionType", + "traits": { + "smithy.api#documentation": "The type of the pipeline execution.
" + } + }, + "rollbackMetadata": { + "target": "com.amazonaws.codepipeline#PipelineRollbackMetadata", + "traits": { + "smithy.api#documentation": "The metadata about the execution pertaining to stage rollback.
" + } } }, "traits": { "smithy.api#documentation": "Represents information about an execution of a pipeline.
" } }, + "com.amazonaws.codepipeline#PipelineExecutionFilter": { + "type": "structure", + "members": { + "succeededInStage": { + "target": "com.amazonaws.codepipeline#SucceededInStageFilter", + "traits": { + "smithy.api#documentation": "Filter for pipeline executions where the stage was successful in the current pipeline\n version.
" + } + } + }, + "traits": { + "smithy.api#documentation": "The pipeline execution to filter on.
" + } + }, "com.amazonaws.codepipeline#PipelineExecutionId": { "type": "string", "traits": { @@ -5754,6 +5820,18 @@ "smithy.api#error": "client" } }, + "com.amazonaws.codepipeline#PipelineExecutionOutdatedException": { + "type": "structure", + "members": { + "message": { + "target": "com.amazonaws.codepipeline#Message" + } + }, + "traits": { + "smithy.api#documentation": "The specified pipeline execution is outdated and cannot be used as a target pipeline execution for rollback.
", + "smithy.api#error": "client" + } + }, "com.amazonaws.codepipeline#PipelineExecutionStatus": { "type": "enum", "members": { @@ -5819,6 +5897,12 @@ "smithy.api#documentation": "The status of the pipeline execution.
\nInProgress: The pipeline execution is currently running.
\nStopped: The pipeline execution was manually stopped. For more information,\n see Stopped Executions.
\nStopping: The pipeline execution received a request to be manually stopped.\n Depending on the selected stop mode, the execution is either completing or\n abandoning in-progress actions. For more information, see Stopped Executions.
\nSucceeded: The pipeline execution was completed successfully.
\nSuperseded: While this pipeline execution was waiting for the next stage to\n be completed, a newer pipeline execution advanced and continued through the\n pipeline instead. For more information, see Superseded Executions.
\nFailed: The pipeline execution was not completed successfully.
\nStatus summary for the pipeline.
" + } + }, "startTime": { "target": "com.amazonaws.codepipeline#Timestamp", "traits": { @@ -5854,6 +5938,18 @@ "traits": { "smithy.api#documentation": "The method that the pipeline will use to handle multiple executions. The default\n mode is SUPERSEDED.
" } + }, + "executionType": { + "target": "com.amazonaws.codepipeline#ExecutionType", + "traits": { + "smithy.api#documentation": "Type of the pipeline execution.
" + } + }, + "rollbackMetadata": { + "target": "com.amazonaws.codepipeline#PipelineRollbackMetadata", + "traits": { + "smithy.api#documentation": "The metadata for the stage execution to be rolled back.
" + } } }, "traits": { @@ -5944,6 +6040,20 @@ "smithy.api#error": "client" } }, + "com.amazonaws.codepipeline#PipelineRollbackMetadata": { + "type": "structure", + "members": { + "rollbackTargetPipelineExecutionId": { + "target": "com.amazonaws.codepipeline#PipelineExecutionId", + "traits": { + "smithy.api#documentation": "The pipeline execution ID to which the stage will be rolled back.
" + } + } + }, + "traits": { + "smithy.api#documentation": "The metadata for the stage execution to be rolled back.
" + } + }, "com.amazonaws.codepipeline#PipelineStageDeclarationList": { "type": "list", "member": { @@ -6952,6 +7062,17 @@ "smithy.api#error": "client" } }, + "com.amazonaws.codepipeline#Result": { + "type": "enum", + "members": { + "ROLLBACK": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "ROLLBACK" + } + } + } + }, "com.amazonaws.codepipeline#RetryStageExecution": { "type": "operation", "input": { @@ -7073,6 +7194,85 @@ "smithy.api#pattern": "^arn:aws(-[\\w]+)*:iam::[0-9]{12}:role/" } }, + "com.amazonaws.codepipeline#RollbackStage": { + "type": "operation", + "input": { + "target": "com.amazonaws.codepipeline#RollbackStageInput" + }, + "output": { + "target": "com.amazonaws.codepipeline#RollbackStageOutput" + }, + "errors": [ + { + "target": "com.amazonaws.codepipeline#ConflictException" + }, + { + "target": "com.amazonaws.codepipeline#PipelineExecutionNotFoundException" + }, + { + "target": "com.amazonaws.codepipeline#PipelineExecutionOutdatedException" + }, + { + "target": "com.amazonaws.codepipeline#PipelineNotFoundException" + }, + { + "target": "com.amazonaws.codepipeline#StageNotFoundException" + }, + { + "target": "com.amazonaws.codepipeline#UnableToRollbackStageException" + }, + { + "target": "com.amazonaws.codepipeline#ValidationException" + } + ], + "traits": { + "smithy.api#documentation": "Rolls back a stage execution.
" + } + }, + "com.amazonaws.codepipeline#RollbackStageInput": { + "type": "structure", + "members": { + "pipelineName": { + "target": "com.amazonaws.codepipeline#PipelineName", + "traits": { + "smithy.api#documentation": "The name of the pipeline for which the stage will be rolled back.
", + "smithy.api#required": {} + } + }, + "stageName": { + "target": "com.amazonaws.codepipeline#StageName", + "traits": { + "smithy.api#documentation": "The name of the stage in the pipeline to be rolled back.
", + "smithy.api#required": {} + } + }, + "targetPipelineExecutionId": { + "target": "com.amazonaws.codepipeline#PipelineExecutionId", + "traits": { + "smithy.api#documentation": "The pipeline execution ID for the stage to be rolled back to.
", + "smithy.api#required": {} + } + } + }, + "traits": { + "smithy.api#input": {} + } + }, + "com.amazonaws.codepipeline#RollbackStageOutput": { + "type": "structure", + "members": { + "pipelineExecutionId": { + "target": "com.amazonaws.codepipeline#PipelineExecutionId", + "traits": { + "smithy.api#documentation": "The execution ID of the pipeline execution for the stage that has been rolled\n back.
", + "smithy.api#required": {} + } + } + }, + "traits": { + "smithy.api#output": {} + } + }, "com.amazonaws.codepipeline#S3ArtifactLocation": { "type": "structure", "members": { @@ -7311,6 +7511,12 @@ "smithy.api#documentation": "The actions included in a stage.
", "smithy.api#required": {} } + }, + "onFailure": { + "target": "com.amazonaws.codepipeline#FailureConditions", + "traits": { + "smithy.api#documentation": "The method to use when a stage has not completed successfully. For example, configuring this field for rollback will roll back a failed stage automatically to the last successful pipeline execution in the stage.
" + } } }, "traits": { @@ -7333,6 +7539,12 @@ "smithy.api#documentation": "The status of the stage, or for a completed stage, the last status of the\n stage.
\nA status of cancelled means that the pipeline’s definition was updated before the\n stage execution could be completed.
\nThe type of pipeline execution for the stage, such as a rollback pipeline execution.
" + } } }, "traits": { @@ -7704,6 +7916,20 @@ "com.amazonaws.codepipeline#String": { "type": "string" }, + "com.amazonaws.codepipeline#SucceededInStageFilter": { + "type": "structure", + "members": { + "stageName": { + "target": "com.amazonaws.codepipeline#StageName", + "traits": { + "smithy.api#documentation": "The name of the stage for filtering for pipeline executions where the stage was successful in the current pipeline\n version.
" + } + } + }, + "traits": { + "smithy.api#documentation": "Filter for pipeline executions that have successfully completed the stage in the current pipeline version.
" + } + }, "com.amazonaws.codepipeline#Tag": { "type": "structure", "members": { @@ -8038,9 +8264,33 @@ "traits": { "smithy.api#enumValue": "WebhookV2" } + }, + "ManualRollback": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "ManualRollback" + } + }, + "AutomatedRollback": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "AutomatedRollback" + } } } }, + "com.amazonaws.codepipeline#UnableToRollbackStageException": { + "type": "structure", + "members": { + "message": { + "target": "com.amazonaws.codepipeline#String" + } + }, + "traits": { + "smithy.api#documentation": "Unable to roll back the stage. The cause might be if the pipeline version has changed\n since the target pipeline execution was deployed, the stage is currently running, or an\n incorrect target pipeline execution ID was provided.
", + "smithy.api#error": "client" + } + }, "com.amazonaws.codepipeline#UntagResource": { "type": "operation", "input": {