AWS CodePipeline将Spring Boot应用程序部署到Elastic BeansTalk

问题描述 投票:0回答:1

我通过3个步骤为SpringBoot Java应用程序构建了一个简单的CodePipeline:

  • 来源:从GitHub获取来源
  • 构建:一个ja​​r文件
  • 部署:到AWS Elastic Beanstalk实例

1和2步骤成功通过,而部署步骤失败。我在Elastic Beanstalk日志中看到的唯一错误:

01_configure_application.sh] : Activity execution failed, because: Executing: /usr/bin/unzip -o -d /var/app/staging /opt/elasticbeanstalk/deploy/appsource/source_bundle
  FileMagic v0.7.1: compiled magic version [5.21] does not match with shared library magic version [5.37]
  Archive:  /opt/elasticbeanstalk/deploy/appsource/source_bundle
    inflating: /var/app/staging/microservices/my-service/target/my-service.jar  
  Unable to launch application as the source bundle does not contain either a file named application.jar or a Procfile.
  Unable to launch application as the source bundle does not contain either a file named application.jar or a Procfile. (ElasticBeanstalk::ExternalInvocationError)
caused by: Executing: /usr/bin/unzip -o -d /var/app/staging /opt/elasticbeanstalk/deploy/appsource/source_bundle
  FileMagic v0.7.1: compiled magic version [5.21] does not match with shared library magic version [5.37]
  Archive:  /opt/elasticbeanstalk/deploy/appsource/source_bundle
    inflating: /var/app/staging/microservices/my-service/target/my-service.jar  
  Unable to launch application as the source bundle does not contain either a file named application.jar or a Procfile.
  Unable to launch application as the source bundle does not contain either a file named application.jar or a Procfile. (Executor::NonZeroExitStatus)

我的构建说明:

build:
  commands:
      - mvn -P ci --settings settings.xml install -DskipTests
artifacts:
  files:
     - microservices/my-service/target/my-service.jar

如果我使用AWS Web Interface将这个jar直接部署到AWS Elastic Beanstalk,它会完美地工作。

[请帮帮我。我准备按需共享任何其他配置。

amazon-web-services amazon-elastic-beanstalk aws-codepipeline
1个回答
0
投票
问题出在工件的子文件夹中,无法像我的Buildspec中那样使用工件位置:

artifacts: files: - microservices/my-service/target/my-service.jar

唯一正确的方法是folder/myapp.jar,例如:

artifacts: files: - target/my-service.jar

因此,如果不同,则应在maven配置中指定outputDirectory
© www.soinside.com 2019 - 2024. All rights reserved.