Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code Pipeline: Stage(step) skipping condition support #32045

Open
2 tasks
pitayapj opened this issue Nov 7, 2024 · 4 comments
Open
2 tasks

Code Pipeline: Stage(step) skipping condition support #32045

pitayapj opened this issue Nov 7, 2024 · 4 comments
Labels
@aws-cdk/pipelines CDK Pipelines library effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2

Comments

@pitayapj
Copy link

pitayapj commented Nov 7, 2024

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

@pitayapj pitayapj added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Nov 7, 2024
@github-actions github-actions bot added the @aws-cdk/pipelines CDK Pipelines library label Nov 7, 2024
@ashishdhingra ashishdhingra self-assigned this Nov 7, 2024
@ashishdhingra ashishdhingra added p2 investigating This issue is being investigated and/or work is in progress to resolve the issue. and removed needs-triage This issue or PR still needs to be triaged. labels Nov 7, 2024
@ashishdhingra
Copy link
Contributor

@ashishdhingra ashishdhingra added effort/medium Medium work item – several days of effort and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. labels Nov 7, 2024
@ashishdhingra ashishdhingra removed their assignment Nov 7, 2024
@pitayapj
Copy link
Author

pitayapj commented Nov 8, 2024

@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
            }),
          ],
        },
       ]
});

@pitayapj
Copy link
Author

pitayapj commented Nov 8, 2024

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"
            },
          }
      ]
    }
  ]
});

@pitayapj
Copy link
Author

Just want to add something. Additions of L3 construct for both codepipeline and cdk pipeline would be amazing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/pipelines CDK Pipelines library effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2
Projects
None yet
Development

No branches or pull requests

2 participants