Amazon web services 部署。战争到AWS

Amazon web services 部署。战争到AWS,amazon-web-services,amazon-s3,Amazon Web Services,Amazon S3,我想把战争从詹金斯部署到云端 您能告诉我如何将Jenkins的war文件部署到本地的AWS Bean Stape吗 我尝试使用Jenkins后期处理插件将工件复制到S3,但出现以下错误: ERROR: Failed to upload files java.io.IOException: put Destination [bucketName=https:, objectName=/s3-eu-west-1.amazonaws.com/bucketname/test.war]: com.amaz

我想把战争从詹金斯部署到云端

您能告诉我如何将Jenkins的war文件部署到本地的AWS Bean Stape吗

我尝试使用Jenkins后期处理插件将工件复制到S3,但出现以下错误:

ERROR: Failed to upload files java.io.IOException: put Destination [bucketName=https:, objectName=/s3-eu-west-1.amazonaws.com/bucketname/test.war]:
com.amazonaws.AmazonClientException: Unable to execute HTTP request: Connect to s3.amazonaws.com/s3.amazonaws.com/ timed out at hudson.plugins.s3.S3Profile.upload(S3Profile.java:85) at hudson.plugins.s3.S3BucketPublisher.perform(S3BucketPublisher.java:143)

在这方面已经做了一些工作

基本上,这只是添加一个生成后任务来运行标准命令行部署脚本

在参考页面中,假设您在Jenkins上安装了构建后任务插件和AWS命令行工具:

步骤1

在Jenkins作业配置屏幕中,添加一个“构建后操作”并选择插件“将工件发布到S3 bucket”,指定源(在我们的例子中,我们使用Maven,因此源是target/。war和destination是您的S3 bucket名称)

步骤2

然后,将“后期构建任务”(如果没有,这是Maven repo中的一个插件)添加到上面的同一部分(“后期构建操作”),并将其拖到“将工件发布到S3存储桶”下面。这一点很重要,我们希望确保在继续脚本之前将war文件上载到S3

在“生成后任务”部分中,确保选中“仅当前面的所有步骤都成功时运行脚本”复选框

在脚本文本区域中,输入脚本路径以自动部署(在下面的步骤3中描述)。对我们来说,我们放了这样的东西:

<path_to_script_file>/deploy.sh "$VERSION_NUMBER" "$VERSION_DESCRIPTION"
/deploy.sh“$VERSION\u NUMBER”“$VERSION\u DESCRIPTION”
$VERSION_编号和$VERSION_描述是Jenkins的构建参数,必须在触发部署时指定。这两个变量都将用于AEB部署

步骤3

剧本

#!/bin/sh
export AWS_CREDENTIAL_FILE=<path_to_your aws.key file>
export PATH=$PATH:<path to bin file inside the "api" folder inside the AEB Command line tool (A)>
export PATH=$PATH:<path to root folder of s3cmd (B)>

//get the current time and append to the name of .war file that's being deployed.
//This will create a unique identifier for each .war file and allow us to rollback easily.
current_time=$(date +"%Y%m%d%H%M%S")
original_file="app.war"
new_file="app_$current_time.war"

//Rename the deployed war file with the new name.
s3cmd mv "s3://<your S3 bucket>/$original_file" "s3://<your S3 bucket>/$new_file"

//Create application version in AEB and link it with the renamed WAR file
elastic-beanstalk-create-application-version -a "Hoiio App" -l "$1" -d "$2" -s "<your S3 bucket>/$new_file"
#/垃圾箱/垃圾箱
导出AWS\u凭证\u文件=
导出路径=$PATH:
导出路径=$PATH:
//获取当前时间并附加到正在部署的.war文件的名称。
//这将为每个.war文件创建一个唯一的标识符,并允许我们轻松回滚。
当前时间=$(日期+%Y%m%d%H%m%S)
原始文件=“app.war”
新建\u file=“app\u$current\u time.war”
//使用新名称重命名已部署的war文件。
s3cmd mv“s3:///$原始\u文件”“s3:///$新\u文件”
//在AEB中创建应用程序版本,并将其与重命名的WAR文件链接
elastic beanstalk创建应用程序版本-一个“HOIO应用程序”-l“$1”-d“$2”-s”/$new_文件”

我尝试过这一点,但本教程似乎是针对在EC2上运行的Jenkins的,但在我的例子中,我让Jenkins在本地机器上运行。这不重要。您应该仍然能够将war文件复制到s3存储桶中,并使用新的war参数重新启动EBC实例。我使用beanstalker maven插件完成了这项工作,该插件性质类似。如果您尝试了此操作,请在您的问题中添加任何错误消息或结果,这样我们就可以帮助解决问题,而不是提供指向您已经查看过的页面的链接。错误:无法上载文件java.io.IOException:put Destination[bucketName=https:,objectName=/s3-eu-west-1.amazonaws.com/bucketName/test.war]:com.amazonaws.amazonClient异常:无法执行HTTP请求:连接到s3.amazonaws.com/s3.amazonaws.com/在hudson.plugins.s3.S3Profile.upload(S3Profile.java:85)在hudson.plugins.s3.S3BucketPublisher.perform(S3BucketPublisher.java:143)处超时