我的应用程序当前正在通过TeamCity和Gradle的混合部署在AWS Opsworks中,但我需要利用部署挂钩来执行一些任务,例如Liquibase迁移,符号链接等。
看来我有Opsworks识别部署文件夹中存在正确的RB文件,但是当它运行它们时,我会看到隐藏的类型转换错误,看似缺少属性。我尝试手动将这些添加到自定义JSON作为解决方法无济于事。
以下是错误,部署JSON以及似乎导致问题的参数。我只是想知道如何填写属性值并通过错误。提前谢谢。
TypeError
---------
no implicit conversion of nil into String
Cookbook Trace:
---------------
/var/lib/aws/opsworks/cache.stage2/cookbooks/deploy/definitions/opsworks_deploy.rb:154:in `block (3 levels) in from_file'
Resource Declaration:
---------------------
# In /var/lib/aws/opsworks/cache.stage2/cookbooks/deploy/definitions/opsworks_deploy.rb
65: deploy deploy[:deploy_to] do
66: provider Chef::Provider::Deploy.const_get(deploy[:chef_provider])
67: keep_releases deploy[:keep_releases]
68: repository deploy[:scm][:repository]
69: user deploy[:user]
70: group deploy[:group]
71: revision deploy[:scm][:revision]
72: migrate deploy[:migrate]
73: migration_command deploy[:migrate_command]
74: environment deploy[:environment].to_hash
75: create_dirs_before_symlink( deploy[:create_dirs_before_symlink] )
76: symlink_before_migrate( deploy[:symlink_before_migrate] )
77: action deploy[:action]
78:
79: if deploy[:application_type] == 'rails' && node[:opsworks][:instance][:layers].include?('rails-app')
80: restart_command "sleep #{deploy[:sleep_before_restart]} && #{node[:opsworks][:rails_stack][:restart_command]}"
81: end
82:
The attribute which seems to be generating the issue:
params {:deploy_data=>{"deploy_to"=>"/srv/www/deploy-name", (tons of skipped params) ..., :name=>nil}
Current JSON under which the error is thrown:
{"deploy": {"deploy-name": {"scm": {"user": "accesskey", "password": "secretkey" }}}}
Adjusted JSON in an attempt to resolve:
{"deploy": {"deploy-name": {"scm": {"user": "accesskey", "password": "secretkey" }}, "name": "deploy-name"}}
答案 0 :(得分:0)
事实证明,使用nil的隐式类型转换,其中编译行上的属性为nil是误导性的。
问题来自于部署钩子本身(没有指示部署钩子中的错误代码)。一旦解决了这个问题就没有了。