maven - 如何将 WAR 文件从 s3 部署到 AWS EC2?

标签 maven amazon-web-services jenkins amazon-s3 amazon-ec2

我有一个AWS EC2实例在运行,并且有一个maven项目在tomcat7上运行。我尝试过的是,我使用 Jenkins 进行 CI。因此,每当 Git-hub 发生新推送时,Jenkins 就会开始构建,构建完成后,它将把 war 文件上传到 AWS S3。 我遇到的问题是,我没有办法将 war 文件部署到 AWS Ec2 实例。

我尝试使用代码部署,其中一次它向我显示它仅支持 tar、tar.gz 和 zip 是否有任何方法可以将 war 文件从 S3 部署到 AWS EC2 实例。

谢谢。

最佳答案

您可以使用Amazon Code Deploy它可以管理来自 S3 存储桶的部署,并可以自动部署到文件/脚本的 EC2 实例。

来自Overview of a Deployment

Here's how it works:

  1. First, you create deployable content – such as web pages, executable files, setup scripts, and so on – on your local development machine or similar environment, and then you add an application specification file (AppSpec file). The AppSpec file is unique to AWS CodeDeploy; it defines the deployment actions you want AWS CodeDeploy to execute. You bundle your deployable content and the AppSpec file into an archive file, and then upload it to an Amazon S3 bucket or a GitHub repository. This archive file is called an application revision (or simply a revision).
  2. Next, you provide AWS CodeDeploy with information about your deployment, such as which Amazon S3 bucket or GitHub repository to pull the revision from and which set of instances to deploy its contents to. AWS CodeDeploy calls a set of instances a deployment group. A deployment group contains individually tagged instances, Amazon EC2 instances in Auto Scaling groups, or both.
    Each time you successfully upload a new application revision that you want to deploy to the deployment group, that bundle is set as the target revision for the deployment group. In other words, the application revision that is currently targeted for deployment is the target revision. This is also the revision that will be pulled for automatic deployments.
  3. Next, the AWS CodeDeploy agent on each instance polls AWS CodeDeploy to determine what and when to pull the revision from the specified Amazon S3 bucket or GitHub repository.
  4. Finally, the AWS CodeDeploy agent on each instance pulls the target revision from the specified Amazon S3 bucket or GitHub repository and, using the instructions in the AppSpec file, deploys the contents to the instance.

AWS CodeDeploy keeps a record of your deployments so that you can get information such as deployment status, deployment configuration parameters, instance health, and so on.

好处是代码部署没有额外成本,您只需为管道中使用的资源(EC2、S3)付费

关于maven - 如何将 WAR 文件从 s3 部署到 AWS EC2?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34786231/

相关文章:

python - 如何使用 PynamoDB 在代码中使用访问凭据而不是环境变量

amazon-web-services - Aws Organization - 将成员(member)账户移交给其他方

git - Jenkins 选择了错误的 git 二进制文件

java - 使用 Android Test Orchestrator 执行 Instrumented 测试时无法获取异常的堆栈跟踪

Maven如何为父pom设置绝对路径

java - 如何使用idlj-maven-plugin生成java文件

maven - 我可以在 maven 2 和 maven 3 之间共享一个 maven 存储库吗

amazon-web-services - AWS-SAM:如何重新使用 Route53 域而不是重新创建它?

jenkins - 如何将 Jenkins API 响应限制为最后 n 个构建 ID

java - 使用 IDE 运行 Spring-boot 的 main