Capistrano - 查找当前部署的版本

问题描述 投票:3回答:2

使用Capistrano 3.4,是否有命令查找当前部署的版本(分支和标记/修订版)?

在已部署的根目录中有一个文件revisions.log。我可以创建一个自定义命令来解析它,但特别是在回滚的情况下,解析它并不是很容易:

Branch master (at 21) deployed as release 20151207160059 by Marco Branch master (at 22) deployed as release 20151207180000 by Marco Marco rolled back to release 20151207160059

capistrano capistrano3
2个回答
3
投票

在release文件夹中有一个名为REVISION的文件,其中包含已部署的VCS修订标识符。你可以简单地cat得到修改。


0
投票

按照您的初步想法,获取当前版本(通过https://stackoverflow.com/a/34156436/2832282)并使用revision.log文件查找匹配的分支名称

revision_string = Rails.root.join('..', '..', 'revisions.log').readlines.detect { |rev| rev.includes?(revision_from_revision_file) }

“分支机构生产(6d68c9415e4d89a6c3119d68a164e50274a2e790)由Cyril部署为20190301085412发布”

然后

revision = revision_string.match(
  /^Branch (?<branch>.+) \(at (?<hash>\w+)\) deployed as release (?<release>\w+)/
)
revision['branch'] # => 'production'
© www.soinside.com 2019 - 2024. All rights reserved.