简体   繁体   中英

Elastic Beanstalk | CodePipeline will not deploy .war file correctly

I'm having a problem with my .war file deployment through CodePipeline (using CodeBuild) to my Elastic Beanstalk environment. After a successful pipeline deployment, it throws a 404 error (see picture).

However, when I upload the .war file from my project code directly into my Elastic Beanstalk environment, it works just fine.

Ideally, I want to just be able to run the CodePipeline to update the versioning.

My CodeBuild (buildspec) -

version: 0.2

phases:
  install:
    runtime-versions:
      java: corretto11

  build:
    commands:
      - ls -la
      - cd prod/
      - mvn clean
      - mvn install
  # post_build:
  #   commands:
artifacts:
  files:
  - backend/target/backend-0.0.1-SNAPSHOT.war
  # name: artifact 
  base-directory: prod/

404 Error -

错误图片

I've tried this as well and it still gives me a 404 error

version: 0.2

phases:
  install:
    runtime-versions:
      java: corretto11

  build:
    commands:
      - ls -la
      - cd prod/
      - mvn clean
      - mvn install
post_build:
    commands:
      - mv backend/target/backend-0.0.1-SNAPSHOT.war ROOT.war
artifacts:
  files:
      - ROOT.war

AWS Elastic Beanstalk expects to find and run a ROOT.war at root directory.

ROOT.war runs at myapp.elasticbeanstalk.com. In a single WAR source bundle, the application always runs at the root path. ( Source )

You have two options to resolve this

  1. Make sure that your artifact is named ROOT.war and is found at root level (in contrary to backend/target/backend-0.0.1-SNAPSHOT.war )
  2. Use the post_build phase in your CodePipeline to rename and move the file adequately (the easier option).

Option 2 approach:

post_build:
    commands:
      - mv backend/target/backend-0.0.1-SNAPSHOT.war ROOT.war

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM