简体   繁体   English

如何通过 Jenkins 在自动缩放模式下将应用程序代码推送到 Amazon EC2 服务器?

[英]How to push application code to Amazon EC2 servers in autoscaling mode, via Jenkins?

I have an environment in AWS where EC2 instances are in autoscaling mode, ie new instances spin up as per the load on deployed instances.我在 AWS 中有一个环境,其中 EC2 实例处于自动缩放模式,即新实例根据部署实例的负载启动。

Now, if I want to integrate this environment with Jenkins, how can I push my codes from Github to these EC2 instances, where my application is deployed.现在,如果我想将此环境与 Jenkins 集成,如何将我的代码从 Github 推送到部署我的应用程序的这些 EC2 实例。 And with every change in my code version, Github should invoke EC2 instances to have the same versions deployed, and also every new instances should be created with this updated version of code, ie every autoscaled instances must have the same code version running.并且随着我的代码版本的每次更改,Github 应该调用 EC2 实例来部署相同的版本,并且每个新实例都应该使用此更新版本的代码创建,即每个自动缩放的实例必须运行相同的代码版本。 Please help.请帮忙。

I assume you have an executable version of your latest code on a deploy server.我假设您在部署服务器上有最新代码的可执行版本。 You can do this by forcing Jenkins to deploy your code when a new commit is made on a specific branch in GitHub.您可以通过在 GitHub 中的特定分支上进行新提交时强制 Jenkins 部署您的代码来实现此目的。 Then all you need is an AMI for your Auto Scaling Group that has a job/task which runs let's say every 5 minutes (based on how long one single task takes).然后,您只需要一个用于 Auto Scaling 组的 AMI,它有一个作业/任务,假设每 5 分钟运行一次(基于单个任务需要多长时间)。 This job/task fetches (copies) the code from the deploy server and then starts the application.此作业/任务从部署服务器获取(复制)代码,然后启动应用程序。 As an example, in Windows Task Scheduler you can add two actions to a task: one for updating (eg a simple robocopy) the code and one for running the app.例如,在 Windows 任务计划程序中,您可以向任务添加两个操作:一个用于更新(例如简单的机器人复制)代码,另一个用于运行应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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