如何在Capistrano 3中设置环境变量?

时间:2021-01-15 22:44:28

In Capistrano 2, you could do something like this:

在Capistrano 2中,你可以这样做:

set :default_environment, {
  'PATH' => 'PATH=$PATH:/opt/rubies/ruby-2.1.1/bin'
}

Is there an equivalent in cap 3?

是否有上限3的等价物?

2 个解决方案

#1


15  

use:

使用:

set :default_env, {
  'PATH' => 'PATH=$PATH:/opt/rubies/ruby-2.1.1/bin'
}

as of at least capistrano 3.1

截至至少capistrano 3.1

#2


0  

Perhaps a bit late but...

也许有点晚了......

Capistrano 3 uses a specia syntax for environment

Capistrano 3使用specia语法来表示环境

on roles :app do
  with some_env: "foobar" do
    ...
  end
end

In the above example, within the with/end block capistrano sets the environment variable SOME_ENV to "foobar"

在上面的示例中,在with / end块中,capistrano将环境变量SOME_ENV设置为“foobar”

see https://github.com/capistrano/sshkit#users-working-directories-environment-variables-and-umask

请参阅https://github.com/capistrano/sshkit#users-working-directories-environment-variables-and-umask

#1


15  

use:

使用:

set :default_env, {
  'PATH' => 'PATH=$PATH:/opt/rubies/ruby-2.1.1/bin'
}

as of at least capistrano 3.1

截至至少capistrano 3.1

#2


0  

Perhaps a bit late but...

也许有点晚了......

Capistrano 3 uses a specia syntax for environment

Capistrano 3使用specia语法来表示环境

on roles :app do
  with some_env: "foobar" do
    ...
  end
end

In the above example, within the with/end block capistrano sets the environment variable SOME_ENV to "foobar"

在上面的示例中,在with / end块中,capistrano将环境变量SOME_ENV设置为“foobar”

see https://github.com/capistrano/sshkit#users-working-directories-environment-variables-and-umask

请参阅https://github.com/capistrano/sshkit#users-working-directories-environment-variables-and-umask