3

I'm trying to setup a CI/CD pipeline for a dotnet app which uses AWS Lambda and AWS CDK for infrastructure. The source is on github and we have a Jenkins pipeline which runs the tests and publishes the artifacts. I want to use the artifact and deploy (or better use Code Deploy)

Can I use CodePipeline to run cdk deploy? How can I use CodeDeploy to do a dotnet test and dotnet publish? and then pass on the artifact to CodePipeline

theabrar
  • 95
  • 1
  • 8

3 Answers3

7

CodePipeline is a workflow service, it by itself cannot execute any commands. What you need is a Build/Test service like CodeBuild and/or Jenkins as part of the CodePipeline. This is where you will run the commands like 'cdk deploy', 'dotnet test' and 'dotnet publish'.

Once the Deployment artifacts are ready in the Build environment (using the aforementioned commands), the next CodePipeline Stage can use them to deploy - this is where a Service like CodeDeploy will be used.

CodePipeline is just orchestrating the workflow between the building block services like CodeCommit (Source), CodeBuild (Build/Test) and CodeDeploy (Deploy). There are many more integrations available.

Hope this helps.

shariqmaws
  • 8,152
  • 1
  • 16
  • 35
0

There are example from AWS on this AWS CDK home page. https://docs.aws.amazon.com/cdk/latest/guide/codepipeline_example.html

The working implementation on this using code commit is as below, it has screen shots and github link.

https://nikhilbhojcloud.blogspot.com/2019/08/code-pipeline-using-aws-cdk-for-lambda.html

Apart from this AWS CDK team is building CI/CD for CDK applications. https://github.com/aws/aws-cdk/tree/master/packages/%40aws-cdk/app-delivery

0

You should use CodeBuild not CodeDeploy to do a dotnet test. CodePipeline has three stages

  1. Source
  2. CodeBuild
  3. CodeDeploy

For your use case github is the source. CodeBuild can be used to build/test your application. And CodeDeploy to deploy the build artifacts to your environment.

In order use codeBuild you must provide build specification reference. follow the link for further more information like how to do it in codebuild. https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html

Mounick
  • 171
  • 5