Search code examples
springamazon-web-servicestomcat8aws-code-deployaws-codebuild

CodeBuild and CodeDeploy Success But Not Running Server for maven javaweb application


I'm using codestart on aws server my codecommit and codebuild success but not deployed on tomcat server. These are buildspec.yml and appspec.yml

buildspec.yml

    version: 0.1

    phases:
      install:
        commands:
          - echo Entering install phase...
          - wget http://mirror.olnevhost.net/pub/apache/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz
          - tar xzvf apache-maven-3.3.9-bin.tar.gz -C /opt/
          - export PATH=/opt/apache-maven-3.3.9/bin:$PATH
      pre_build:
        commands:
          - echo Entering pre_build phase...
          - echo Nothing to do in the pre_build phase...
      build:
        commands:
          - echo Entering build phase...
          - echo Build started on `date`
          - mvn -f pom.xml compile war:exploded
      post_build:
        commands:
          - echo Entering post_build phase...
          - echo Build completed on `date`
          - mv target/ROOT .
    artifacts:
      type: zip
      files:
        - target/ROOT.war
        - appspec.yml
      discard-paths: yes

appspec.yml

    version: 0.0
    os: linux
    files:
      - source: ./ROOT.jar
        destination: /

Solution

    • buildspec.yml (need to modify)
    • appspec.yml (delete)

    buildspec.yml

        version: 0.1
    
        phases:
          install:
            commands:
              - echo Entering install phase...
              - wget http://mirror.olnevhost.net/pub/apache/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz
              - tar xzvf apache-maven-3.3.9-bin.tar.gz -C /opt/
              - export PATH=/opt/apache-maven-3.3.9/bin:$PATH
          pre_build:
            commands:
              - echo Entering pre_build phase...
              - echo Nothing to do in the pre_build phase...
          build:
            commands:
              - echo Entering build phase...
              - echo Build started on `date`
              - mvn -f pom.xml compile war:exploded
          post_build:
            commands:
              - echo Entering post_build phase...
              - echo Build completed on `date`
              - mv target/ROOT .
        artifacts:
          type: zip
          files:
            - 'ROOT/WEB-INF/**/*'
            - 'ROOT/WEB-INF/classes/*'
            - 'ROOT/WEB-INF/classes/**/*'
            - 'ROOT/WEB-INF/lib/*'
            - 'ROOT/WEB-INF/lib-provided/*'
            - 'ROOT/WEB-INF/js/*'
            - 'ROOT/org/springframework/boot/loader/*' //if you are using spring boot application