LoginSignup
2
2

More than 5 years have passed since last update.

Capistrano3でhttps経由でソースコードをcloneする

Posted at

gitのソースコードをhttpsプロトコル経由でcloneする場合には、git_http_usernameとgit_http_passwordを指定する必要があります。

deploy.rb

set :repo_url, "https://my_repo.git"
set :git_http_username, "my_name"
set :git_http_password, "my_password"

方法はStackOverflowに記載されていました
(http://stackoverflow.com/questions/14253913/capistrano-deploy-from-git-http-repo)

が、↑の内容のままではエラーになり、ソースコードを調べたところCapistrano3では微妙にパラメータ名が変更されたようでした。

capistrano-3.8.0/lib/capistrano/scm/git.rb

  def git_repo_url
    if fetch(:git_http_username) && fetch(:git_http_password)
      URI.parse(repo_url).tap do |repo_uri|
        repo_uri.user     = fetch(:git_http_username)
        repo_uri.password = CGI.escape(fetch(:git_http_password))
      end.to_s
    elsif fetch(:git_http_username)
      URI.parse(repo_url).tap do |repo_uri|
        repo_uri.user = fetch(:git_http_username)
      end.to_s
    else
      repo_url
    end
  end
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2