Home » Php » Capistrano: fetch method does not return value at the beginning of deploy.rb

Capistrano: fetch method does not return value at the beginning of deploy.rb

Posted by: admin October 26, 2017 Leave a comment

Questions:

I am new to Capistrano.

Basically I want to use client name recieved from the user in the deploy_to path.

    set :client, ask('client name','demo')
    fetch :client`

Then I set deploy_to as

    set :deploy_to, '/php/ca/stg/#{fetch :client}/#{fetch :application}'
    set :shared_directory, '/php/ca/stg/#{fetch :client}/shared'

Unfortunatelly fetch does not resolve a value. It stays like #{fetch :client} in the path.

However, it resolves perfectly in tasks. For example:

    before :starting, :check_branch do
      run_locally do
        unless execute :git, 'ls-remote --exit-code', fetch(:repo_url), fetch(:branch), { raise_on_non_zero_exit: false }
           fatal "Specified branch or tag #{fetch(:branch)} for client #{fetch(:client)} does not exist in remote repository."
           exit 1
        end
      end
    end

I guess I am missing something or I do not understand how this method works. As I said I just started with Capistrano. I am trying to use it to deploy my Laravel applications.

What would be a solution to set dynamic variables using user’s input?

Thank you.

Answers:

Leave a Reply

Your email address will not be published. Required fields are marked *