CL7: Configure Build & Deploy

Task: Configure Build & Deploy

Create Parameter Store inside AWS Systems Manager

Store your secrets (user & password) for your SAP Cloud Platform tenant = SCP_USER & SCP_PW.

You can also store tenant organization and space info, if you like (SCP_ORG, SCP_SPACE). Details be found inside the SAP Cloud Platform cockpit, as shown below: Node

AWS Systems Manager - Parameter Store (make sure to stick to the same AWS region)

Node

Create a new file called ‘buildspec.yml

version: 0.2

phases:
  install:
    runtime-versions:
      java: openjdk8
      
  build:
    commands:
       - mvn package
       
reports: #New
  SurefireReportsUnitTest: # CodeBuild will create a report group called "SurefireReports".
    files: #Store all of the files
      - '*.xml'
    base-directory: 'unit-tests/target/surefire-reports' # Location of the reports
  SurefireReportsIntegrationTest: # CodeBuild will create a report group called "SurefireReports".
    files: #Store all of the files
      - '*.xml'
    base-directory: 'integration-tests/target/surefire-reports' # Location of the reports

artifacts:
  files:
    - application/target/*
    - deployspec.yml
    - manifest.yml

Note: Integration test only works properly with openjdk8 => Chosse Ubuntu as AWS CodeBuild Image!

Create a new file called ‘deployspec.yml

version: 0.2

env:
  parameter-store:
    SCP_USER: SCP_USER
    SCP_PW: SCP_PW

phases:
  install:
    runtime-versions:
      java: openjdk8
      
  build:
    commands:
       - wget -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | apt-key add
       - echo "deb https://packages.cloudfoundry.org/debian stable main" | tee /etc/apt/sources.list.d/cloudfoundry-cli.list
       - apt-get update
       - apt-get install cf-cli
       - cf api https://api.cf.eu10.hana.ondemand.com #SCP@AWS FRA - Adjust if required
       - echo "Deploying as"
       - echo $SCP_USER
       - cf login -u $SCP_USER -p $SCP_PW -o <OrgId> -s <SpaceId> #Adjust
       - cf push

This should look like the following

Node

Finally add the code to your repository. In terminal, execute

$ git add *
$ git commit -m 'initial setup'
$ git push

Sample Output:

Node

Validate the CodeCommit Repository

Node