- Newest
- Most votes
- Most comments
There are now two different CodePipeline operations for these two requirements:
- Redeploy a previously built artifact without rebuilding it: roll back the Deploy stage to a previously successful pipeline execution.
- Build an arbitrary Git commit or a newly created Git tag: start a normal execution with a source revision override.
For the first requirement, CodePipeline stage rollback is the direct solution. When you roll back the Deploy stage, CodePipeline creates a new rollback execution and uses the variables and artifacts from the target execution. The Source and Build stages are not rerun, so this redeploys the artifact that was already produced by that earlier successful execution.
In the console, open the pipeline, choose Start rollback on the Deploy stage, and select the successful execution that contains the artifact you want. The CLI equivalent is:
aws codepipeline list-pipeline-executions --pipeline-name MyPipeline --filter succeededInStage={stageName=Deploy} aws codepipeline rollback-stage --pipeline-name MyPipeline --stage-name Deploy --target-pipeline-execution-id <successful-execution-id>
Use the name of the stage containing the CodeDeploy action. Do not roll back the Build stage if the goal is to avoid rebuilding.
Important rollback limits are:
- A Source stage cannot be rolled back.
- The target must have succeeded in that stage.
- The target execution must belong to the current pipeline structure version.
- A rollback execution cannot itself be used as the next rollback target.
- The stage must not already be running.
You can also configure an OnFailure stage condition with a ROLLBACK result for automatic deployment rollback. Remember that stage rollback reuses CodePipeline variables and artifacts; it does not automatically reverse database migrations or other external side effects performed by deployment scripts.
For the second requirement, an S3 source archive is no longer required merely to choose a CodeCommit commit. CodePipeline supports COMMIT_ID source revision overrides. A tag-created CodeCommit EventBridge event contains detail.commitId; an input transformer can pass that value as the source action's sourceRevisions[].revisionValue. Alternatively, start it manually:
aws codepipeline start-pipeline-execution --name MyPipeline --source-revisions actionName=Source,revisionType=COMMIT_ID,revisionValue=<commit-id>
That starts a normal Source/Build/Deploy execution for the selected commit. It is useful for a new tag, but it is not the no-rebuild rollback path. Use Deploy-stage rollback when the desired artifact already exists in a successful pipeline execution.
Official references:
answered a month ago
Relevant content
asked 3 years ago
asked 5 years ago
asked 3 years ago
