Amazon web services Codedeploy部署在BeforeInstall事件中失败,错误为“;退出:0:需要数字参数";

Amazon web services Codedeploy部署在BeforeInstall事件中失败,错误为“;退出:0:需要数字参数";,amazon-web-services,aws-code-deploy,Amazon Web Services,Aws Code Deploy,我的appspec文件中有以下内容(yaml已验证)—— 在安装前步骤中,我间歇性地出现以下错误: Error Code ScriptFailed Script Name beforeInstall.sh Message Script at specified location: beforeInstall.sh failed with exit code 255 Log Tail LifecycleEvent - BeforeInstall Script - beforeInstall.sh

我的appspec文件中有以下内容(yaml已验证)——

在安装前步骤中,我间歇性地出现以下错误:

Error Code ScriptFailed
Script Name beforeInstall.sh
Message Script at specified location: beforeInstall.sh failed with exit code 255
Log Tail

LifecycleEvent - BeforeInstall
Script - beforeInstall.sh
[stderr]/opt/codedeploy-agent/deployment-root/edbe4bd2-3999-4820-b782-42d8aceb18e6/d-4GJ8QS9MG/deployment-archive/beforeInstall.sh: line 1: exit: 0
: numeric argument required
以下是我的beforeInstall.sh文件的内容-

exit 0
请注意,构建会间歇性地成功。我尝试了以下方法-

  • 正在执行beforeInstall.sh文件的dos2unix。运行build并在一些试验后成功(不是在更改后立即),因此不能说这是原因

  • 使用zip文件的新名称将新zip上载到S3(只是为了避免在ec2实例上发生任何缓存)

此外,我发现即使构建成功,实例中也没有发生文件部分中提到的文件更改—没有添加要添加的文件,也没有进行文件修改。然而,一些现有文件的时间戳被修改到今天。奇怪

更新

以下是beforeInstall.sh中的
/var/log/aws/codedeploy agent/codedeploy agent.log
,以及
出口1
的日志跟踪-

2016-08-01 12:41:01 WARN  [codedeploy-agent(9507)]: InstanceAgent::Plugins::CodeDeployPlugin::HookExecutor: Script at specified location: beforeInstall.sh is not executable.  Trying to make it executable.
2016-08-01 12:41:01 INFO  [codedeploy-agent(9507)]: Version file found in /opt/codedeploy-agent/.version.
2016-08-01 12:41:01 INFO  [codedeploy-agent(9507)]: [Aws::CodeDeployCommand::Client 200 0.087513 0 retries] put_host_command_complete(command_status:"Failed",diagnostics:{format:"JSON",payload:"{\"error_code\":4,\"script_name\":\"beforeInstall.sh\",\"message\":\"Script at specified location: beforeInstall.sh run as user sandeepan failed with exit code 255\",\"log\":\"LifecycleEvent - BeforeInstall\\nScript - beforeInstall.sh\\n[stderr]/opt/codedeploy-agent/deployment-root/c71b93a2-8561-41e2-b90f-d638548e7b4c/d-A36YRE23H/deployment-archive/beforeInstall.sh: line 1: exit: 0\\r: numeric argument required\\n\"}"},host_command_identifier:"WyJjb20uYW1hem9uLmFwb2xsby5kZXBsb3ljb250cm9sLmRvbWFpbi5Ib3N0Q29tbWFuZElkZW50aWZpZXIiLHsiZGVwbG95bWVudElkIjoiQ29kZURlcGxveS91cy1lYXN0LTEvUHJvZC9hcm46YXdzOnNkczp1cy1lYXN0LTE6Mzc3NzAzOTYxOTk4OmRlcGxveW1lbnQvZC1BMzZZUkUyM0giLCJob3N0SWQiOiJhcm46YXdzOmVjMjp1cy1lYXN0LTE6Mzc3NzAzOTYxOTk4Omluc3RhbmNlL2ktZWZmYzU1YWEiLCJjb21tYW5kTmFtZSI6IkFmdGVySW5zdGFsbCIsImNvbW1hbmRQb3NpdGlvbiI6NSwiY29tbWFuZEF0dGVtcHQiOjF9XQ==")

2016-08-01 12:41:01 ERROR [codedeploy-agent(9507)]: InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller: Error during perform: InstanceAgent::Plugins::CodeDeployPlugin::ScriptError - Script at specified location: beforeInstall.sh run as user sandeepan failed with exit code 255 - /opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/hook_executor.rb:153:in `execute_script'
/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/hook_executor.rb:110:in `block (2 levels) in execute'
/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/hook_executor.rb:98:in `each'
/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/hook_executor.rb:98:in `block in execute'
/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/hook_executor.rb:168:in `create_script_log_file_if_needed'
/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/hook_executor.rb:96:in `execute'
/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/command_executor.rb:133:in `block (3 levels) in map'
/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/command_executor.rb:124:in `each'
/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/command_executor.rb:124:in `block (2 levels) in map'
/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/command_executor.rb:62:in `execute_command'
/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/command_poller.rb:132:in `process_command'
/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/command_poller.rb:65:in `perform'
/opt/codedeploy-agent/lib/instance_agent/agent/base.rb:28:in `run'
/opt/codedeploy-agent/lib/instance_agent/runner/child.rb:38:in `block in run'
/opt/codedeploy-agent/lib/instance_agent/runner/child.rb:55:in `with_error_handling'
/opt/codedeploy-agent/lib/instance_agent/runner/child.rb:37:in `run'
/opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/child.rb:70:in `block in run_with_error_handling'
/opt/codedeploy-agent/lib/instance_agent/runner/child.rb:55:in `with_error_handling'
/opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/child.rb:69:in `run_with_error_handling'
/opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/child.rb:33:in `block in start'
/opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/child.rb:22:in `loop'
/opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/child.rb:22:in `start'
/opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/master.rb:202:in `block in spawn_child'
/opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/master.rb:200:in `fork'
/opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/master.rb:200:in `spawn_child'
/opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/master.rb:192:in `block in spawn_children'
/opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/master.rb:191:in `times'
/opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/master.rb:191:in `spawn_children'
/opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/master.rb:134:in `start'
/opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/master.rb:37:in `block in start'
/opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/master.rb:36:in `fork'
/opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/master.rb:36:in `start'
/opt/codedeploy-agent/bin/codedeploy-agent:37:in `block (2 levels) in <main>'
/opt/codedeploy-agent/vendor/gems/gli-2.5.6/lib/gli/command_support.rb:130:in `call'
/opt/codedeploy-agent/vendor/gems/gli-2.5.6/lib/gli/command_support.rb:130:in `execute'
/opt/codedeploy-agent/vendor/gems/gli-2.5.6/lib/gli/app_support.rb:262:in `block in call_command'
/opt/codedeploy-agent/vendor/gems/gli-2.5.6/lib/gli/app_support.rb:275:in `call'
/opt/codedeploy-agent/vendor/gems/gli-2.5.6/lib/gli/app_support.rb:275:in `call_command'
/opt/codedeploy-agent/vendor/gems/gli-2.5.6/lib/gli/app_support.rb:69:in `run'
/opt/codedeploy-agent/bin/codedeploy-agent:84:in `<main>'
2016-08-01 12:41:01警告[codedeploy agent(9507)]:InstanceAgent::Plugins::CodeDeployPlugin::HookExecutor:指定位置的脚本:beforeInstall.sh不可执行。试图使其可执行。
2016-08-01 12:41:01信息[codedeploy agent(9507)]:在/opt/codedeploy agent/.Version中找到版本文件。
2016-08-01 12:41:01信息[codedeploy agent(9507)]:[Aws::CodeDeployCommand::Client 200 0.087513 0次重试]放置主机命令完成(命令状态:“失败”,诊断:{格式:“JSON”,有效负载:{“错误代码”:4,“脚本名称”:“beforeInstall.sh\”,“消息”:“指定位置的脚本:beforeInstall.sh以用户SandePan身份运行失败,退出代码为255\”,“log\”:\“LifecycleeEvent-beforeInstall\\nScript-beforeInstall.sh\\n[stderr]/opt/codedeploy agent/deployment root/c71b93a2-8561-41e2-b90f-D63858E7B4C/d-A36YRE23H/deployment archive/beforeInstall.sh:第1行:退出:0\\r:需要数字参数\\\}“},主机\u命令\u标识符:2.一个中国的一个中国的一个中国的一个中国的一个中国的一个中国的一个中国的一个中国的一个中国的一个中国的一个中国的一个中国的一个中国的一个中国的一个中国的一个中国的一个中国的一个中国的一个中国的一个中国的一个中国的一个中国的一个中国的一个中国的一个中国的一个中国的一个中国的中国的一个中国的一个中国的一个中国的一个中国的一个中国的一个中国的中国的一个中国的一个中国的中国的一个中国的中国的一个中国的一个中国的中国的一个中国的中国的一个中国的中国的一个中国的中国的中国的一个中国的一个中国的中国的中国的一个中国的中国的中国的一个中国的一个中国的中国的中国的一个中国的中国的一个中国的中国的中国的一个中国的中国的中国的中国的中国5ZDGFSBCisimNvbW1hbmRQb3NpdGlvbiI6NSwiY29tbWFuZEF0dGVtcHQiOjF9XQ==”)
2016-08-01 12:41:01错误[codedeploy agent(9507)]:InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller:执行过程中出错:InstanceAgent::Plugins::CodeDeployPlugin::ScriptError-指定位置的脚本:beforeInstall.sh以用户sandeepan身份运行失败,退出代码为255-/opt/codedeploy agent/lib/instance_agent/Plugins/codedeploy/hook_executor.rb:153:in'execute_Script'
/opt/codedeploy agent/lib/instance_agent/plugins/codedeploy/hook_executor.rb:110:in`block(2层)in execute'
/opt/codedeploy-agent/lib/instance\u-agent/plugins/codedeploy/hook\u-executor.rb:98:in'each'
/opt/codedeploy-agent/lib/instance\u-agent/plugins/codedeploy/hook\u-executor.rb:98:in'block-in-execute'
/opt/codedeploy agent/lib/instance\u agent/plugins/codedeploy/hook\u executor.rb:168:in`create\u script\u log\u file\u if\u needed'
/opt/codedeploy-agent/lib/instance\u-agent/plugins/codedeploy/hook\u-executor.rb:96:in'execute'
/opt/codedeploy-agent/lib/instance\u-agent/plugins/codedeploy/command\u-executor.rb:133:in'block(3层)in-map'
/opt/codedeploy-agent/lib/instance\u-agent/plugins/codedeploy/command\u-executor.rb:124:in'each'
/opt/codedeploy agent/lib/instance_agent/plugins/codedeploy/command_executor.rb:124:in`map中的block(2层)'
/opt/codedeploy agent/lib/instance_agent/plugins/codedeploy/command_executor.rb:62:in'execute_command'
/opt/codedeployagent/lib/instance_agent/plugins/codedeploy/command_poller.rb:132:in'process_command'
/opt/codedeploy-agent/lib/instance\u-agent/plugins/codedeploy/command\u-poller.rb:65:in'perform'
/opt/codedeploy-agent/lib/instance\u-agent/agent/base.rb:28:in'run'
/opt/codedeploy-agent/lib/instance\u-agent/runner/child.rb:38:in'block-in-run'
/opt/codedeployagent/lib/instance\u agent/runner/child.rb:55:in`with\u error\u handling'
/opt/codedeployagent/lib/instance_agent/runner/child.rb:37:in'run'
/opt/codedeploy-agent/vendor/gems/process\u-manager-0.0.13/lib/process\u-manager/child.rb:70:在“带错误处理的运行块”中
/opt/codedeployagent/lib/instance\u agent/runner/child.rb:55:in`with\u error\u handling'
/opt/codedeploy-agent/vendor/gems/process\u-manager-0.0.13/lib/process\u-manager/child.rb:69:“运行时出错处理”
/opt/codedeploy-agent/vendor/gems/process_-manager-0.0.13/lib/process_-manager/child.rb:33:在“开始时阻止”中
/opt/codedeployagent/vendor/gems/process_manager-0.0.13/lib/process_manager/child.rb:22:in'loop'
/opt/codedeployagent/vendor/gems/process_manager-0.0.13/lib/process_manager/child.rb:22:in'start'
/opt/codedeploy-agent/vendor/gems/process_-manager-0.0.13/lib/process_-manager/master.rb:202:在“生成子对象中的块”中
/opt/codedeployagent/vendor/gems/process_manager-0.0.13/lib/process_manager/master.rb:200:in'fork'
/opt/codedeployagent/vendor/gems/process_manager-0.0.13/lib/process_manager/master.rb:200:in'spawn_child'
/opt/codedeploy-agent/vendor/gems/process_-manager-0.0.13/lib/process_-manager/master.rb:192:in“block in spawn_children”
/opt/codedeployagent/vendor/gems/process_manager-0.0.13/lib/process_manager/master.rb:191:in'times'
/opt/codedeployagent/vendor/gems/process_manager-0.0.13/lib/process_manager/master.rb:191:in'spawn_children'
/opt/codedeployagent/vendor/gems/process_manager-0.0.13/lib/process_manager/master.rb:134:in'start'
/opt/codedeploy-agent/vendor/gems/process_-manager-0.0.13/lib/process_-manager/master.rb:37:in“block-in-start”
/opt/codedeploy agent/vendor/gems/process_manager-0.0.13/lib/
2016-08-01 12:41:01 WARN  [codedeploy-agent(9507)]: InstanceAgent::Plugins::CodeDeployPlugin::HookExecutor: Script at specified location: beforeInstall.sh is not executable.  Trying to make it executable.
2016-08-01 12:41:01 INFO  [codedeploy-agent(9507)]: Version file found in /opt/codedeploy-agent/.version.
2016-08-01 12:41:01 INFO  [codedeploy-agent(9507)]: [Aws::CodeDeployCommand::Client 200 0.087513 0 retries] put_host_command_complete(command_status:"Failed",diagnostics:{format:"JSON",payload:"{\"error_code\":4,\"script_name\":\"beforeInstall.sh\",\"message\":\"Script at specified location: beforeInstall.sh run as user sandeepan failed with exit code 255\",\"log\":\"LifecycleEvent - BeforeInstall\\nScript - beforeInstall.sh\\n[stderr]/opt/codedeploy-agent/deployment-root/c71b93a2-8561-41e2-b90f-d638548e7b4c/d-A36YRE23H/deployment-archive/beforeInstall.sh: line 1: exit: 0\\r: numeric argument required\\n\"}"},host_command_identifier:"WyJjb20uYW1hem9uLmFwb2xsby5kZXBsb3ljb250cm9sLmRvbWFpbi5Ib3N0Q29tbWFuZElkZW50aWZpZXIiLHsiZGVwbG95bWVudElkIjoiQ29kZURlcGxveS91cy1lYXN0LTEvUHJvZC9hcm46YXdzOnNkczp1cy1lYXN0LTE6Mzc3NzAzOTYxOTk4OmRlcGxveW1lbnQvZC1BMzZZUkUyM0giLCJob3N0SWQiOiJhcm46YXdzOmVjMjp1cy1lYXN0LTE6Mzc3NzAzOTYxOTk4Omluc3RhbmNlL2ktZWZmYzU1YWEiLCJjb21tYW5kTmFtZSI6IkFmdGVySW5zdGFsbCIsImNvbW1hbmRQb3NpdGlvbiI6NSwiY29tbWFuZEF0dGVtcHQiOjF9XQ==")

2016-08-01 12:41:01 ERROR [codedeploy-agent(9507)]: InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller: Error during perform: InstanceAgent::Plugins::CodeDeployPlugin::ScriptError - Script at specified location: beforeInstall.sh run as user sandeepan failed with exit code 255 - /opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/hook_executor.rb:153:in `execute_script'
/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/hook_executor.rb:110:in `block (2 levels) in execute'
/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/hook_executor.rb:98:in `each'
/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/hook_executor.rb:98:in `block in execute'
/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/hook_executor.rb:168:in `create_script_log_file_if_needed'
/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/hook_executor.rb:96:in `execute'
/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/command_executor.rb:133:in `block (3 levels) in map'
/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/command_executor.rb:124:in `each'
/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/command_executor.rb:124:in `block (2 levels) in map'
/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/command_executor.rb:62:in `execute_command'
/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/command_poller.rb:132:in `process_command'
/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/command_poller.rb:65:in `perform'
/opt/codedeploy-agent/lib/instance_agent/agent/base.rb:28:in `run'
/opt/codedeploy-agent/lib/instance_agent/runner/child.rb:38:in `block in run'
/opt/codedeploy-agent/lib/instance_agent/runner/child.rb:55:in `with_error_handling'
/opt/codedeploy-agent/lib/instance_agent/runner/child.rb:37:in `run'
/opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/child.rb:70:in `block in run_with_error_handling'
/opt/codedeploy-agent/lib/instance_agent/runner/child.rb:55:in `with_error_handling'
/opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/child.rb:69:in `run_with_error_handling'
/opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/child.rb:33:in `block in start'
/opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/child.rb:22:in `loop'
/opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/child.rb:22:in `start'
/opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/master.rb:202:in `block in spawn_child'
/opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/master.rb:200:in `fork'
/opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/master.rb:200:in `spawn_child'
/opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/master.rb:192:in `block in spawn_children'
/opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/master.rb:191:in `times'
/opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/master.rb:191:in `spawn_children'
/opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/master.rb:134:in `start'
/opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/master.rb:37:in `block in start'
/opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/master.rb:36:in `fork'
/opt/codedeploy-agent/vendor/gems/process_manager-0.0.13/lib/process_manager/master.rb:36:in `start'
/opt/codedeploy-agent/bin/codedeploy-agent:37:in `block (2 levels) in <main>'
/opt/codedeploy-agent/vendor/gems/gli-2.5.6/lib/gli/command_support.rb:130:in `call'
/opt/codedeploy-agent/vendor/gems/gli-2.5.6/lib/gli/command_support.rb:130:in `execute'
/opt/codedeploy-agent/vendor/gems/gli-2.5.6/lib/gli/app_support.rb:262:in `block in call_command'
/opt/codedeploy-agent/vendor/gems/gli-2.5.6/lib/gli/app_support.rb:275:in `call'
/opt/codedeploy-agent/vendor/gems/gli-2.5.6/lib/gli/app_support.rb:275:in `call_command'
/opt/codedeploy-agent/vendor/gems/gli-2.5.6/lib/gli/app_support.rb:69:in `run'
/opt/codedeploy-agent/bin/codedeploy-agent:84:in `<main>'
exit: 0 : numeric argument required

/bin/sh^M: bad interpreter: No such file or directory