如何使用capistrano部署指定的commit SHA

时间:2022-10-15 07:24:09

I am wondering how I can target a specific commit SHA in Git for deployment, using Capistrano? It should be something like

我想知道如何使用Capistrano将Git中的一个特定的commit SHA作为部署的目标?应该是这样的

cap deploy --version=<sha targeted>

Can't seem to find the answer to this after a lot of searching.

经过大量的搜寻,似乎找不到这个问题的答案。

4 个解决方案

#1


63  

For Capistrano 2.9 until 3.0:

对于Capistrano 2.9至3.0:

cap -S revision=80655da8d80aaaf92ce5357e7828dc09adb00993 deploy

For older versions of Capistrano, you can deploy a particular git commit/tree/branch/tag by doing this:

对于Capistrano的旧版本,您可以这样部署一个特定的git提交/树/分支/标记:

cap -s branch=80655da8d80aaaf92ce5357e7828dc09adb00993 deploy

In some cases there may be a need of specifying the Environment as an argument as well. production is just an example.

在某些情况下,可能还需要将环境指定为参数。生产只是一个例子。

cap production -S revision=80655da8d80aaaf92ce5357e7828dc09adb00993 deploy

#2


17  

molf's answer didn't work for me (using capistrano 2.11.2). I had to use "revision" instead of branch, like this:

molf的回答对我不起作用(使用capistrano 2.11.2)。我必须使用“修订”而不是“分支”,像这样:

cap -S revision=80655da8d80aaaf92ce5357e7828dc09adb00993 deploy

#3


11  

Capistrano 3

Capistrano 3

In your deploy.rb or stage-specific file like config/deploy/production.rb

在您的部署。rb或特定于阶段的文件,如config/deploy/production.rb

set :branch, ENV.fetch('REVISION', 'master')

This allows you to point to a specific git revision. It accepts a SHA but also anything that resolves to a real revision (e.g. git tag, annotated tag, or branch).

这允许您指向特定的git修订。它接受一个SHA,但它也可以解析为真正的修改(例如git标记、注释标记或分支)。

Use it on the command line by setting the REVISION environment variable, e.g.

通过设置修订环境变量,在命令行上使用它。

bundle exec cap production deploy REVISION=80655da8d80aaaf92ce5357e7828dc09adb00993

bundle exec cap staging deploy REVISION=my-topic-branch

#4


1  

ask :branch, 'master'

问:分支,“大师”

Prompts for input but defaults to 'master' if you press return.

提示输入,但如果您按return,默认为'master'。

#1


63  

For Capistrano 2.9 until 3.0:

对于Capistrano 2.9至3.0:

cap -S revision=80655da8d80aaaf92ce5357e7828dc09adb00993 deploy

For older versions of Capistrano, you can deploy a particular git commit/tree/branch/tag by doing this:

对于Capistrano的旧版本,您可以这样部署一个特定的git提交/树/分支/标记:

cap -s branch=80655da8d80aaaf92ce5357e7828dc09adb00993 deploy

In some cases there may be a need of specifying the Environment as an argument as well. production is just an example.

在某些情况下,可能还需要将环境指定为参数。生产只是一个例子。

cap production -S revision=80655da8d80aaaf92ce5357e7828dc09adb00993 deploy

#2


17  

molf's answer didn't work for me (using capistrano 2.11.2). I had to use "revision" instead of branch, like this:

molf的回答对我不起作用(使用capistrano 2.11.2)。我必须使用“修订”而不是“分支”,像这样:

cap -S revision=80655da8d80aaaf92ce5357e7828dc09adb00993 deploy

#3


11  

Capistrano 3

Capistrano 3

In your deploy.rb or stage-specific file like config/deploy/production.rb

在您的部署。rb或特定于阶段的文件,如config/deploy/production.rb

set :branch, ENV.fetch('REVISION', 'master')

This allows you to point to a specific git revision. It accepts a SHA but also anything that resolves to a real revision (e.g. git tag, annotated tag, or branch).

这允许您指向特定的git修订。它接受一个SHA,但它也可以解析为真正的修改(例如git标记、注释标记或分支)。

Use it on the command line by setting the REVISION environment variable, e.g.

通过设置修订环境变量,在命令行上使用它。

bundle exec cap production deploy REVISION=80655da8d80aaaf92ce5357e7828dc09adb00993

bundle exec cap staging deploy REVISION=my-topic-branch

#4


1  

ask :branch, 'master'

问:分支,“大师”

Prompts for input but defaults to 'master' if you press return.

提示输入,但如果您按return,默认为'master'。