简体   繁体   English

尝试 `git archive master` 时,Capistrano 部署失败

[英]Capistrano deploy fails when trying `git archive master`

I want to deploy my rails project by using Capistrano, but it fails when trying cap production deploy:updating .我想使用 Capistrano 部署我的 rails 项目,但是在尝试cap production deploy:updating时它失败了。

This is error message.这是错误信息。 (I replaced domain and project name.) (我替换了域和项目名称。)

[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message.
 INFO [f71ac456] Running /usr/bin/env mkdir -p /tmp/exmaple/ on example.com
DEBUG [f71ac456] Command: /usr/bin/env mkdir -p /tmp/exmaple/
 INFO [f71ac456] Finished in 0.736 seconds with exit status 0 (successful).
DEBUG Uploading /tmp/exmaple/git-ssh.sh 0.0%
 INFO Uploading /tmp/exmaple/git-ssh.sh 100.0%
 INFO [c1918686] Running /usr/bin/env chmod +x /tmp/exmaple/git-ssh.sh on example.com
DEBUG [c1918686] Command: /usr/bin/env chmod +x /tmp/exmaple/git-ssh.sh
 INFO [c1918686] Finished in 0.062 seconds with exit status 0 (successful).
DEBUG [905ddc4a] Running /usr/bin/env [ -f /var/www/example.com/repo/HEAD ] on example.com
DEBUG [905ddc4a] Command: [ -f /var/www/example.com/repo/HEAD ]
DEBUG [905ddc4a] Finished in 0.053 seconds with exit status 0 (successful).
 INFO The repository mirror is at /var/www/example.com/repo
DEBUG [e9c1eeda] Running /usr/bin/env if test ! -d /var/www/example.com/repo; then echo "Directory does not exist '/var/www/example.com/repo'" 1>&2; false; fi on example.com
DEBUG [e9c1eeda] Command: if test ! -d /var/www/example.com/repo; then echo "Directory does not exist '/var/www/example.com/repo'" 1>&2; false; fi
DEBUG [e9c1eeda] Finished in 0.053 seconds with exit status 0 (successful).
 INFO [9bd77dfe] Running /usr/bin/env git remote update on example.com
DEBUG [9bd77dfe] Command: cd /var/www/example.com/repo && /usr/bin/env git remote update
DEBUG [9bd77dfe]    Fetching origin
 INFO [9bd77dfe] Finished in 0.068 seconds with exit status 0 (successful).
DEBUG [4fe5034f] Running /usr/bin/env if test ! -d /var/www/example.com/repo; then echo "Directory does not exist '/var/www/example.com/repo'" 1>&2; false; fi on example.com
DEBUG [4fe5034f] Command: if test ! -d /var/www/example.com/repo; then echo "Directory does not exist '/var/www/example.com/repo'" 1>&2; false; fi
DEBUG [4fe5034f] Finished in 0.059 seconds with exit status 0 (successful).
 INFO [d75938a4] Running /usr/bin/env mkdir -p /var/www/example.com/releases/20140105125534 on example.com
DEBUG [d75938a4] Command: cd /var/www/example.com/repo && ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/exmaple/git-ssh.sh /usr/bin/env mkdir -p /var/www/example.com/releases/20140105125534 )
 INFO [d75938a4] Finished in 0.057 seconds with exit status 0 (successful).
 INFO [9f7ea103] Running /usr/bin/env git archive master | tar -x -C /var/www/example.com/releases/20140105125534 on example.com
DEBUG [9f7ea103] Command: cd /var/www/example.com/repo && ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/exmaple/git-ssh.sh /usr/bin/env git archive master | tar -x -C /var/www/example.com/releases/20140105125534 )
DEBUG [9f7ea103]    fatal: Not a valid object name

And this is my Capistrano setting file production.rb .这是我的 Capistrano 设置文件production.rb

set :application, 'example'
set :repo_url, '~/git-repos/example.com.git'

set :deploy_to, '/var/www/example.com'
set :scm, :git
set :branch, 'master'

set :keep_releases, 5

namespace :deploy do

  desc 'Restart application'
  task :restart do
    on roles(:app), in: :sequence, wait: 5 do
    end
  end

  after :restart, :clear_cache do
    on roles(:web), in: :groups, limit: 3, wait: 10 do
    end
  end

  after :finishing, 'deploy:cleanup'
end

I logged in remote server, and cd /var/www/example.com/repo , and git archive master , then get same error: fatal: Not a valid object name .我登录远程服务器,然后cd /var/www/example.com/repogit archive master ,然后得到相同的错误: fatal: Not a valid object name

What should I do solve this problem?我该怎么做才能解决这个问题?

After I manually do git push origin master , deploy end without error.在我手动执行git push origin master ,部署结束没有错误。

It seems first git push must have done manually.似乎首先git push必须手动完成。

将您的 deploy.rb 中的分支设置为您的回购中存在的分支...可能是您拥有 main 而不是 master...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM