1
+ version : 0.2
2
+
3
+ env :
4
+ parameter-store :
5
+ DOCKER_REGISTRY_USERNAME : /cicd/docker-credentials/username
6
+ DOCKER_REGISTRY_PASSWORD : /cicd/docker-credentials/password
7
+ DOCKER_REGISTRY_URL : /cicd/docker-registry/url
8
+ SONAR_TOKEN : /cicd/sonar/sonar-token
9
+ phases :
10
+ install :
11
+ runtime-versions :
12
+ python : 3.11
13
+ java : corretto17
14
+ pre_build :
15
+ commands :
16
+ - echo "Installing dependencies..."
17
+ - echo "Performing Trivy file scan before building the image..."
18
+ # - wget https://github.com/aquasecurity/trivy/releases/download/v0.19.2/trivy_0.19.2_Linux-64bit.tar.gz
19
+ # - tar zxvf trivy_0.19.2_Linux-64bit.tar.gz
20
+ # - export PATH=$PATH:$PWD
21
+ # - trivy filesystem --exit-code 0 --no-progress . >> trivyfilescan.txt
22
+ # - echo "Downloading and installing OWASP Dependency-Check..."
23
+ # - wget https://github.com/jeremylong/DependencyCheck/releases/download/v7.0.2/dependency-check-7.0.2-release.zip
24
+ # - unzip dependency-check-7.0.2-release.zip
25
+ # - export SONAR_SCANNER_VERSION=4.7.0.2747
26
+ # - export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux
27
+ # - curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip
28
+ # - unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
29
+ # - export PATH=$SONAR_SCANNER_HOME/bin:$PATH
30
+ # - export SONAR_SCANNER_OPTS="-server"
31
+
32
+ build :
33
+ commands :
34
+ - echo "Running tests..."
35
+ - echo "Building Docker image..."
36
+ # - echo "$DOCKER_REGISTRY_PASSWORD" | docker login -u "$DOCKER_REGISTRY_USERNAME" --password-stdin "$DOCKER_REGISTRY_URL"
37
+ # - docker build -t "$DOCKER_REGISTRY_URL/$DOCKER_REGISTRY_USERNAME/swiggy:latest" .
38
+ # - docker push "$DOCKER_REGISTRY_URL/$DOCKER_REGISTRY_USERNAME/swiggy:latest"
39
+ # post_build:
40
+ # commands:
41
+ # - echo "Performing Trivy image scan after building the image..."
42
+ # - aws ses send-email --from "madithati123@gmail.com" --to "madithatisreedhar123@gmail.com" --subject "CodeBuild Status: $CODEBUILD_BUILD_ID" --text "Build status: $CODEBUILD_BUILD_STATUS" --region "ap-south-1"
43
+
44
+ # # - trivy image "$DOCKER_REGISTRY_USERNAME/swiggy:latest" >> trivyimage.txt
45
+ # # - echo "Running OWASP Dependency-Check scan..."
46
+ # # - cd dependency-check/bin
47
+ # # - ./dependency-check.sh --scan . --format ALL
48
+ # # - echo "Build completed successfully!"
49
+ # # - echo "Running SonarQube analysis result"
50
+ # # - sonar-scanner -Dsonar.projectKey=swiggy -Dsonar.sources=. -Dsonar.host.url=http://65.1.1.149:9000/
51
+ # #- aws ses send-email --from "madithati123@gmail.com" --to "madithatisreedhar123@gmail.com" --subject "CodeBuild Status: $CODEBUILD_BUILD_ID" --text "Build status: $CODEBUILD_BUILD_STATUS" --region "ap-south-1"
52
+ # # Update with your preferred AWS region
53
+
54
+ post_build :
55
+ commands :
56
+ - aws ses send-email \
57
+ --from "madithati123@gmail.com" \
58
+ --to "madithati123@gmail.com" \
59
+ --subject "CodeBuild Status : $CODEBUILD_BUILD_ID" \
60
+ --text "Build status : $CODEBUILD_BUILD_STATUS" \
61
+ --region "us-east-1" # Update with your preferred AWS region
62
+
63
+
64
+ artifacts :
65
+ files :
66
+ - appspec.yaml
0 commit comments