Code Pipeline: Stage(step) skipping condition support
Describe the feature
Pretty early but code pipeline now support skipping stage base on various of condition. One of them is variable's value and it would be so much helpful if CDK support it.
https://aws.amazon.com/about-aws/whats-new/2024/10/aws-codepipeline-skipping-stage/
According to docment below, CF already supporting it https://docs.aws.amazon.com/codepipeline/latest/userguide/stage-conditions.html#stage-conditions-onsuccess
Use Case
I want to use pipeline variable and skipping stage base on it.
Proposed Solution
No response
Other Information
No response
Acknowledgements
- [ ] I may be able to implement this feature request
- [ ] This feature might incur a breaking change
CDK version used
2
Environment details (OS name and version, etc.)
MacOS
- In Configure conditions for a stage,
- AWS::CodePipeline::Pipeline StageDeclaration supports
OnFailureandOnSuccessproperties.OnSuccessspecifies AWS::CodePipeline::Pipeline SuccessConditions, which representsConditionsproperty that is an array of [Condition](AWS::CodePipeline::Pipeline Condition) objects.OnFailurespecifies AWS::CodePipeline::Pipeline FailureConditions.
- In CDK,
- At L1 CfnPipeline construct level, stages are declared using StageDeclarationProperty interface. This interface support
onSuccessandonFailureproperties (in addition to other properties not exposed in L2 construct)
- At L1 CfnPipeline construct level, stages are declared using StageDeclarationProperty interface. This interface support
@ashishdhingra thank you for your response. I actually want to skip a stage, not condition it with onSuccess and onFailure.
I can see that beforeEntry is also supported but my actions are written is L3, can you tell me how to integrate it with StageDeclarationProperty ?
const pipeline = new codepipeline.Pipeline(this, "pipeline", {
stages: [
{
stageName: "Source",
actions: [sourceAction],
},
{
stageName: "Build",
actions: [
new codepipeline_actions.CodeBuildAction({
project: buildProject,
input: sourceOutput,
outputs: [buildOutput],
variablesNamespace: "BuildImage"
}),
],
},
// skip this if #{BuildImage.MIGRATION_FLAG} = false
{
stageName: "Migration",
actions: [
new codepipeline_actions.CodeBuildAction({
actionName: "Run_Migration",
project: runMigrationBuild,
input: buildOutput, // Pass build output with imageDetail.json
}),
],
},
]
});
I was able to create L3 pipeline then extent with L1 contruct as following. But, still nicer if we can have L3 contruct support stage condition.
const l1Pipeline = pipeline.node.defaultChild as codepipeline.CfnPipeline;
l1Pipeline.addOverride('Properties.Stages.2.BeforeEntry', {
Conditions: [
{
Result: "SKIP",
Rules: [
{
Name: "Skip_Migration",
RuleTypeId: {
Category: "Rule",
Owner: "AWS",
Provider: "VariableCheck",
Version: "1"
},
Configuration: {
Variable: "#{BuildImage.MIGRATION_FLAG}",
Value: "false",
Operator: "EQ"
},
}
]
}
]
});
Just want to add something. Additions of L3 construct for both codepipeline and cdk pipeline would be amazing.
feature implemented: https://github.com/aws/aws-cdk/issues/33511#issuecomment-2753044920
document: https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codepipeline.StageProps.html
Comments on closed issues and PRs are hard for our team to see. If you need help, please open a new issue that references this one.