-
Notifications
You must be signed in to change notification settings - Fork 9
Problem Statement 2 || Solution
- Migrate your https://github.com/OT-TRAINING/DevOps_OT-micro_Training.git to AWS CodeCommit
- Create Your first Pipeline using AWS CodePipeline, keeping Source provider as CodeCommit Repositoryfor OT-Microservice "Salary" Application.
- Using AWS CodBuild and your Buildspec.yml configuration file to build the OT-Microservice "Salary" application.
- Similarly, add all aspects of CI like code stability, code quality and security the way we did for our previous workshop session.
- After building and performing different checks, publish your artifacts to S3 bucket.
- Ideally the pipeline components should have something like below pipeline, and make sure it should cover major aspects of CI/CD
Step 1: Setup git based Repository on AWS CODECOMMIT: Browse the CodeCommit service in AWS and create a repository.

Step 2: Migrate code to git repository
2.1: Browse IAM service > Users > [your user name] > Security credentials

2.2: Generate HTTPS Git credentials for AWS CodeCommit

2.3: Clone the git repository in your workspace using the generted HTTPS Git credentials [ In the solution we are using the approach of HTTPS url for cloning the repository but, we also have option of SSH to clone the repository ]
2.4: Add the code to the clonned repository and push the changes to the repository.

Step 3: Initializing our CODEBUILD project
3.1: Browse CodeBuild and create your first build project.





3.2: Create CodeBuild configuration file, CODEBUILD service uses "buildspec.yaml" file for build configuration. Create a "buildspec.yaml" file in the root directory of repository and push the changes to git repository.
version: 0.2
phases:
build:
commands:
- echo "Welcome to opstree Labs"
3.3: Start build for the CodeDeploy project



Step 4: Setup CODEDEPLOY projects to perform various tasks for CI
4.1: Create "codeStability.yml" configuration file and create "Sprint3HibernateCodeStability" CodeDeploy Project for the same. Keep the configuration same as above just change the buildspec congiguration file path.
version: 0.2
phases:
install:
runtime-versions:
java: corretto11
build:
commands:
- cd salaryv2
- mvn test



4.2: Create "checkstyle.yml" configuration file and create "Sprint3HibernateCheckStyle" CodeDeploy Project for the same. Creation of CheckStyle project will be similar to CodeStability step.
version: 0.2
phases:
install:
runtime-versions:
java: corretto11
build:
commands:
- cd salaryv2
- mvn checkstyle:checkstyle

4.3: Create "findBugs.yml" configuration file and create "Sprint3HibernateFindBugs" CodeDeploy Project for the same.
version: 0.2
phases:
install:
runtime-versions:
java: corretto11
build:
commands:
- cd salaryv2
- mvn findbugs:findbugs

4.4: Create "pmd.yml" configuration file and create "Sprint3HibernatePMD" CodeDeploy Project for the same.
version: 0.2
phases:
install:
runtime-versions:
java: corretto11
build:
commands:
- cd salaryv2
- mvn pmd:pmd
4.5: Create "unitTest.yml" configuration file and create "Sprint3HibernateUnitTest" CodeDeploy Project for the same.
version: 0.2
phases:
install:
runtime-versions:
java: corretto11
build:
commands:
- cd salaryv2
- mvn surefire-report:report
4.6: Create "cobertura.yml" configuration file and create "Sprint3HibernateCobertura" CodeDeploy Project for the same. In this step we have also added a section to publish our cobertura report
version: 0.2
phases:
install:
runtime-versions:
java: corretto11
build:
commands:
- cd salaryv2
- mvn cobertura:cobertura
reports:
CoberturaReports:
files:
- '**/*'
base-directory: 'salaryv2/target/site/cobertura'
file-format: COBERTURAXML


4.7: Create "publishArtifact.yml" configuration file and create "Sprint3HibernatePublishArtifact" CodeDeploy Project for the same, there will be one update in the configuration, as now we will be publishing our Artifact we will have to provide an s3 bucket to put the artifact in. Also, in this step we have also added a section where we have mentioned the artifact that will be generated in build step.
version: 0.2
phases:
install:
runtime-versions:
java: corretto11
build:
commands:
- cd salaryv2
- mvn -Dmaven.test.failure.ignore=true package
artifacts:
files:
- salaryv2/target/salary-0.0.1-SNAPSHOT.jar


Step 5: Setup our CODEPIPELINE project: Browse CodePipeline and create your first pipeline




Step 6: Add Stages to pipeline
6.1: Add manual approval action, to do so, go to edit > edit stage > add action group > Done


6.2.1: Add stage for Code stability Check, to do so, go to edit > add stage

6.2.2: Add action for stability check in CodestabilityCheck stage, to do so, go to edit > edit stage > add action group > Done

6.3.1: Add stage for Static Code Analysis, to do so, go to edit > add stage

6.3.2: Add action for checkstyle check in the StaticCodeAnalysis stage

6.3.3: Add action for find-bug check in the StaticCodeAnalysis stage

6.3.4: Add action for pmd check in the StaticCodeAnalysis stage

6.4.1: Add stage for Code Test Analysis
6.4.2: Add action for unit test in the CodeTestAnalysis stage

6.4.2: Add action for unit test in the CodeTestAnalysis stage

6.5.1: Finally add stage to publish artifact

This pipeline will be invoked on every comming but will require a manual approval in order to proceed to the next stages
