Devops — CICD Pipeline 5: Automate Continuous integration with AWS CodePipeline(Build and Test)
Part 1 — CICD Pipeline-AWS Cloud9
Part 2 — CICD Pipeline — AWS Elastic Beanstalk
Part 3 — CICD Pipeline — Source control using git and CodeCommit
Part 4 — CICD Pipeline — Unit Test with Code Build
You may have worked with processes where your code changes have manually moved from development, testing, and production environments. These types of processes can be slow and prone to error. CI and CD focuses on the automation of steps we need to release our software.
Stages
Source, Build, Test, and Deploy.
Source:
Could be AWS CodeCommit, Github, Bitbucket — for this demonstration i will be making use of AWS CodeCommit
Build:
A build action this could be CodeBuild building my node.js code or any third party integration like Jenkins
Test:
A Test action this again could be CodeBuild running some unit tests against my code or a third party integration and then the code is ready for Deployment.
Deploy:
Now this is where Elastic Beanstalk comes in.
Now consider a scenario where there needs to be manual approval before deployment. maybe even some acceptance test thing going on:
For this, we can add an Approval action. We configure this with an SNS topic, to notify our approvers to view the action in the Console. Now we can think of a Deploy action. For our Deploy action, we have chosen Elastic Beanstalk. We could use other AWS services like, AWS CloudFormation, AWS CodeDeploy, or third parties.
What we will do in this part
you will create a continuous integration (CI) pipeline and automate the build and unit testing process using AWS CodePipeline.
You will also be able to set up a CI/CD pipeline that builds, tests your code every time there is a code change.
LETS DIG IN !!!
1. Create a pipeline using CodePipeline.
- Sign in to the AWS Management Console as the myDeployingUser IAM user.
- In the console, click Services, then click CodePipeline to open the CodePipeline dashboard.
- Make sure you are in the Oregon region.
- Click Create pipeline.
- For Pipeline name, type ci-cd-pipeline
- For Service role, click New service role.
- Click Next.
- For Source provider, select AWS CodeCommit.
- For Repository name, type my-Deploying
- For Branch name, type dev
- Click Next.
- For Build provider, select AWS CodeBuild.
- For Project name, select UnitTests.
- Click Next step.
- On the Add deploy stage screen, click Skip. To confirm this action, click Skip again.
- Click Next step.
- On the Review your pipeline page, scroll down and click Create pipeline. You should see a success message at the top.
- Within a few seconds, the ci-cd-pipeline starts executing the pipeline against the last commit in your CodeCommit repository. CodePipeline kicks off the source stage and you should see an In progress status for the source stage.
- Once the source stage completes, the build stage kicks off. It takes about 3 minutes for the build stage to successfully complete.
- To see the code changes against which the pipeline was executed, click the commit ID in the source stage as shown in the screenshot below. You should see the commit details open up in the CodeCommit dashboard.
- To see the build project details of the pipeline, click the AWS CodeBuild link as shown in the screenshot below. The CodeBuild project details should open up in a new tab.
- To view the code coverage and unit tests details, click the build project hyperlink in the build stage of the ci-cd-pipeline as shown in the screenshot below.
- You should see the build history and details open up in a new tab of your browser. Scroll down to the Build logs section and observe the code coverage and unit tests outputs in the log details.
You have successfully created an AWS CodePipeline and automated the build and unit testing phase of your project. In subsequent exercises, you will commit a change to your application code and observe the pipeline getting triggered automatically to build and test your code change.
we will be moving on to the CD part of the CI/CD process.
Who is excited?