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

pipelines: specify dependencies between pre/post steps #17945

Closed
jeromevdl opened this issue Dec 10, 2021 · 5 comments · Fixed by #18256
Closed

pipelines: specify dependencies between pre/post steps #17945

jeromevdl opened this issue Dec 10, 2021 · 5 comments · Fixed by #18256
Labels
@aws-cdk/pipelines CDK Pipelines library effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p1

Comments

@jeromevdl
Copy link

What is the problem?

When adding multiple pre (or post) steps to a stage, I cannot specify the order. If I'm adding them in the order I'd like (using addPre or addPost), the generated pipeline actions are not in the correct order but alphabetically ordered.

Reproduction Steps

Have a stage and add multiple pre steps:

prodStage.addPre(
      new pipelines.ManualApprovalStep('Validation'),
      new pipelines.CodeBuildStep('Bootstrap', {...})
);

The Validation Step is after the Boostrap one in my template, while it should be before as I've added it before.

If I change "Validation" to "Approval":

prodStage.addPre(
      new pipelines.ManualApprovalStep('Approval'),
      new pipelines.CodeBuildStep('Bootstrap', {...})
);

Approval is now before Bootstrap.

What did you expect to happen?

I expect to have the steps in the order I add them:

prodStage.addPre(
      new pipelines.ManualApprovalStep('Validation'),
      new pipelines.CodeBuildStep('Bootstrap', {...})
);

Should give Validation first and then Bootstrap

What actually happened?

Validation was after Bootstrap.

CDK CLI Version

2.0.0 (build 4b6ce31)

Framework Version

No response

Node.js Version

v17.0.1

OS

macOS BigSur 11.6.1 (M1)

Language

Typescript

Language Version

Typescript (4.5.2)

Other information

No response

@jeromevdl jeromevdl added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Dec 10, 2021
@github-actions github-actions bot added the @aws-cdk/pipelines CDK Pipelines library label Dec 10, 2021
@ryparker ryparker added needs-reproduction This issue needs reproduction. p1 labels Dec 10, 2021
@markusl
Copy link
Contributor

markusl commented Dec 12, 2021

This sounds a bit like #16130 where I encountered a problem about adding a manual approval step using the pre/post commands in the CDK Pipelines.

@FreeWillaert
Copy link

I have a similar issue: no matter what I do - pass an array of steps in addStage, do one or multiple calls to addPost,... - the steps just end up side-by-side, being executed in parallel.
In my case, it's a S3 deploy step and a cloudfront invalidation step.
Using CDK 1.133.

I'm not sure though about the expected behavior: should e.g. multiple calls to addPost effectively result in steps being executed sequentially? There are other cases where parallel execution is desired, and there seems to be no way to specify which is preferred, I think?

@FreeWillaert
Copy link

I finally managed to work around this by creating a wave, adding the stage to it with the first post step, then adding the second post step to the wave.
This results in the two steps being sequential in the code pipeline, in the correct order.

@rix0rrr rix0rrr changed the title pipelines: order of pre/post steps not respected pipelines: specify dependencies between pre/post steps Dec 23, 2021
@rix0rrr rix0rrr added feature-request A feature should be added or improved. effort/small Small work item – less than a day of effort and removed needs-triage This issue or PR still needs to be triaged. labels Dec 23, 2021
@rix0rrr rix0rrr removed their assignment Dec 23, 2021
@kaizencc kaizencc removed bug This issue is a bug. needs-reproduction This issue needs reproduction. labels Jan 3, 2022
@mergify mergify bot closed this as completed in #18256 Jan 4, 2022
mergify bot pushed a commit that referenced this issue Jan 4, 2022
Allows users to specify step dependencies and closes #17945.

Usage:

```ts
const firstStep = new pipelines.ManualApprovalStep('B');
const secondStep = new pipelines.ManualApprovalStep('A');
secondStep.addStepDependency(firstStep);
```

And

```ts
// Step A will depend on step B and step B will depend on step C
const orderedSteps = pipelines.Step.sequence([
  new pipelines.ManualApprovalStep('C');
  new pipelines.ManualApprovalStep('B');
  new pipelines.ManualApprovalStep('A');
]);
```

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

github-actions bot commented Jan 4, 2022

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this issue Feb 21, 2022
Allows users to specify step dependencies and closes aws#17945.

Usage:

```ts
const firstStep = new pipelines.ManualApprovalStep('B');
const secondStep = new pipelines.ManualApprovalStep('A');
secondStep.addStepDependency(firstStep);
```

And

```ts
// Step A will depend on step B and step B will depend on step C
const orderedSteps = pipelines.Step.sequence([
  new pipelines.ManualApprovalStep('C');
  new pipelines.ManualApprovalStep('B');
  new pipelines.ManualApprovalStep('A');
]);
```

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@ssljivic
Copy link

ssljivic commented Dec 21, 2023

I have a similar issue: no matter what I do - pass an array of steps in addStage, do one or multiple calls to addPost,... - the steps just end up side-by-side, being executed in parallel. In my case, it's a S3 deploy step and a cloudfront invalidation step. Using CDK 1.133.

I'm not sure though about the expected behavior: should e.g. multiple calls to addPost effectively result in steps being executed sequentially? There are other cases where parallel execution is desired, and there seems to be no way to specify which is preferred, I think?

@FreeWillaert which class/construct do you use for S3 deploy step and a CloudFront invalidation step?

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/small Small work item – less than a day of effort feature-request A feature should be added or improved. p1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants