git 使用Capistrano部署到Ubuntu服务器

piv4azn7  于 2023-06-20  发布在  Git
关注(0)|答案(1)|浏览(107)

我刚刚开始学习Capistrano,下面是我的配置,我已经安装并尝试使用Circleci
deploy.rb

# config valid for current version and patch releases of Capistrano
lock "~> 3.17.3"

# Application name
set :application, ENV["CIRCLE_PROJECT_REPONAME"]

# Git repository URL
set :repo_url, "git@github.com:organization-name/" + ENV["CIRCLE_PROJECT_REPONAME"] + ".git"

# Git branch you want to pull from. Default branch is :main
set :branch, "main"

# Directory where you want to deploy
set :deploy_to, "/var/www/html"

# Default value for keep_releases is 5
set :keep_releases, 3

production.rb

# Server options
server ENV["DROPLET_IP"],
    user: ENV["DROPLET_USER"],
    roles: %w{app},
    ssh_options: {
        keys: %w(/root/.ssh/id_rsa),
        forward_agent: true,
        auth_methods: %w(publickey)
    }

# Git branch you want to pull from. Overrides Default branch
#set :branch, 'main'
set :branch, 'feature/capistrano'

当管道运行时,我得到错误fatal: 'HEAD' does not appear to be a git repository & Please make sure you have the correct access rights
当我尝试在我的服务器上用git clone git@github.com:organization-name/repo-name.git克隆存储库时,没有任何警告或错误。
我在我的个人git帐户中安装了服务器的ssh。回购存在于我自己的组织帐户中。
我还尝试将deploy.rb中的repo_url设置为

set :repo_url, "https://username:personal_access_token@github.com/organization-name/repo-name.git"

ssh_optionsproduction.rb

ssh_options: {
    #keys: %w(/root/.ssh/id_rsa),
    forward_agent: false,
    auth_methods: %w(password)
}

但是如果我这样做,我会得到NoMethodError: undefined method 'chomp' for nil:NilClass
我不知道我可能做错了什么或错过了什么。任何帮助都是有条件的。
问候

e4yzc0pl

e4yzc0pl1#

一个或一些ENV变量可能等于nil。快看

相关问题