Currently, AWS CodePipeline does not support skipping a stage or an action. However, there is an existing feature request for AWS CodePipeline to support skipping a stage or action. Additionally, there is also a feature request to skip a pipeline execution completely.
While I have no information on whether/when this feature may be released, I encourage you to keep an eye on our What's New pages for any new feature announcements.
As a workaround, you can implement an AWS Step Functions stage in your pipeline. That stage would decide whether to execute particular child stages based on your criteria. In this blog post, you can read about implementing a Step Functions stage in a CodePipeline. Step Functions can call CodeBuild or CodeDeploy actions or even execute another CodePipeline.
If you want to skip some particular actions in a CodeBuild stage itself, you can manually get the last commit message and decide. Here's an idea of what you buildspec script might contain:
CODEBUILD_COMMIT_MESSAGE="$(git log -1 --pretty=%B)" if [[ $CODEBUILD_COMMIT_MESSAGE == *"SKIP_BUILD"* ]]; then echo "Skipping build actions" else build.sh fi
Create new branch when commit id is not availableasked 10 months ago
CDK CodeBuild Pipeline - possible to skip a phase on last github commit message?Accepted Answerasked a month ago
Is it possible to monitor the selected streaming protocol/codec on WSP WorkSpaces?asked 7 months ago
Stop CodePipeline from triggering on every GitHub commit/pushAccepted Answerasked 2 years ago
Github author informationAccepted Answerasked a month ago
CodeBuild job triggered by Githab occasionally gets wrong commitasked 5 months ago
Can I skip one of the action in CodeBuild ? to continue the pipielineAccepted Answerasked 7 months ago
Code Commit Branching ErrorAccepted Answerasked 4 years ago
Use same CodeBuild project for multiple GitHub repositoriesAccepted Answerasked a year ago
CodeBuild hangs at DOWNLOAD_SOURCE phaseasked 4 months ago