1

我正在尝试使用托管在单独的 EC2 实例中的 Jenkins 来创建从 Bitbucket 到 aws EC2 实例的自动化 CI 工作流。

我创建并配置了所需的一切(IAM 角色、aws 客户端和代码部署代理),如下文所述:
https ://pranavpshah.wordpress.com/configure-aws-codedeploy/

顺便说一句,所有实例都基于 ubuntu 并在私有 VPC 中运行,我正在部署一个 node.js 应用程序。

例如,每次推送到 Bitbucket 存储库时,我都可以在 S3 存储桶中成功创建 .zip 构建。但是在代码部署仪表板中,我得到“部署失败没有主机成功”。错误信息。

在此处输入图像描述 每次我启动该过程时,状态“进行中”需要超过 5 分钟。

当部署过程以失败状态完成时,我检查了 /var/log/aws/codedeploy-agent/codedeploy-agent.log 文件,这是我得到的:

2015-12-04 17:17:36 INFO  [codedeploy-agent(28199)]: Stopping master 27971
2015-12-04 17:17:36 INFO  [codedeploy-agent(27971)]: master 27971: Received TERM - stopping children and shutting down
2015-12-04 17:17:36 INFO  [codedeploy-agent(27975)]: InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller of master 27971: Received TERM - setting internal shutting down flag and possibly finishing last run
2015-12-04 17:17:55 INFO  [codedeploy-agent(27975)]: [Aws::CodeDeployCommand::Client 200 60.113784 0 retries] poll_host_command(host_identifier:"arn:aws:ec2:us-west-2:219450671821:instance/i-348913ed")  

2015-12-04 17:17:56 INFO  [codedeploy-agent(27975)]: InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller of master 27971: shutting down
2015-12-04 17:17:57 INFO  [codedeploy-agent(28219)]: master 28219: Spawned child 1/1
2015-12-04 17:17:57 DEBUG [codedeploy-agent(28223)]: Registering Plugins: ["codedeploy"].
2015-12-04 17:17:57 DEBUG [codedeploy-agent(28223)]: Loading plugin codedeploy from /opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/register_plugin
2015-12-04 17:17:57 DEBUG [codedeploy-agent(28223)]: Registered Plugins: #<Set: {InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller}>.
2015-12-04 17:17:57 INFO  [codedeploy-agent(28223)]: On Premises config file does not exist or not readable
2015-12-04 17:17:57 DEBUG [codedeploy-agent(28223)]: InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller: Configuring deploy control client: Region = "us-west-2"
2015-12-04 17:17:57 DEBUG [codedeploy-agent(28223)]: InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller: Deploy control endpoint override = nil
2015-12-04 17:17:57 DEBUG [codedeploy-agent(28223)]: InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller: Initializing Host Agent: Host Identifier = arn:aws:ec2:us-west-2:219450671821:instance/i-348913ed
2015-12-04 17:17:57 DEBUG [codedeploy-agent(28223)]: InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller: Validating CodeDeploy Plugin Configuration
2015-12-04 17:17:57 DEBUG [codedeploy-agent(28223)]: InstanceAgent::Plugins::CodeDeployPlugin::CodeDeployControlCertVerifier: Actual certificate subject is '/C=US/ST=Washington/L=Seattle/O=Amazon.com, Inc./CN=codedeploy-commands.us-west-2.amazonaws.com'
2015-12-04 17:17:57 DEBUG [codedeploy-agent(28223)]: InstanceAgent::Plugins::CodeDeployPlugin::CodeDeployControlCertVerifier: Actual certificate subject is '/C=US/ST=Washington/L=Seattle/O=Amazon.com, Inc./CN=codedeploy-commands.us-west-2.amazonaws.com'
2015-12-04 17:17:57 DEBUG [codedeploy-agent(28223)]: InstanceAgent::Plugins::CodeDeployPlugin::CodeDeployControlCertVerifier: Actual certificate subject is '/C=US/ST=Washington/L=Seattle/O=Amazon.com, Inc./CN=codedeploy-commands.us-west-2.amazonaws.com'
2015-12-04 17:17:57 DEBUG [codedeploy-agent(28223)]: InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller: CodeDeploy Plugin Configuration is valid
2015-12-04 17:17:57 DEBUG [codedeploy-agent(28223)]: InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller: Calling PollHostCommand:
2015-12-04 17:17:58 INFO  [codedeploy-agent(28219)]: Started master 28219 with 1 children
2015-12-04 17:18:58 INFO  [codedeploy-agent(28223)]: [Aws::CodeDeployCommand::Client 200 60.534255 0 retries] poll_host_command(host_identifier:"arn:aws:ec2:us-west-2:219450671821:instance/i-348913ed")  

我在配置中遗漏了什么吗?
请问有什么帮助吗?

4

2 回答 2

0
  1. 我刚刚检查了部署 ID“d-FEPBDKJMC”的详细信息,似乎实例 ID 是“arn:aws:ec2:us-west-2:219450671821:instance/i-d796060e”而不是“arn:aws:ec2 :us-west-2:219450671821:instance/i-348913ed" 在您粘贴的主机代理日志中。所以可能应该检查正确实例的日志。

  2. 部署时跳过了所有生命周期事件,我怀疑主机代理根本没有拉命令。由于您提到该实例在 VPC 下,请确保 Codedeploy 和 S3 端点已列入白名单(我们需要连接到这些端点进行部署)。这里还有一个关于 Codedeploy 与 VPC 合作的文档,请单击安全性:https ://aws.amazon.com/codedeploy/faqs/ 。

于 2015-12-05T00:43:39.723 回答
0

您确定该实例具有访问 S3 的角色吗?我错过了这一点,并且没有附加到我的实例的角色来访问 S3。

请参阅http://docs.aws.amazon.com/codedeploy/latest/userguide/how-to-create-iam-instance-profile.html#getting-started-create-ec2-role-console

于 2016-03-16T06:57:37.277 回答