我在我的服务器上本地托管的gitlab上使用custom_hooks。这是一个代码(我希望在每次提交到存储库时将代码部署到特定文件夹):
#!/opt/gitlab/embedded/bin/ruby
# Fix the PATH so that gitlab-shell can find git-upload-pack and friends.
ENV['PATH'] = '/opt/gitlab/bin:/opt/gitlab/embedded/bin:' + ENV['PATH']
#!/usr/bin/env ruby
# This file was placed here by GitLab. It makes sure that your pushed commits
# will be processed properly.
# 1. Read STDIN (Format: "from_commit to_commit branch_name")
from, to, branch = ARGF.read.split " "
# 2. Only deploy if master branch was pushed
if (branch =~ /master$/) == nil
# puts "Received branch #{branch}, not deploying."
exit
end
# 3. Copy files to deploy directory
deploy_to_dir = File.expand_path('/etc/*specific folder*')
`GIT_WORK_TREE="#{deploy_to_dir}" git checkout -f master`
# puts "DEPLOY: master(#{to}) copied to '#{deploy_to_dir}'"
# 4.TODO: Deployment Tasks
# i.e.: Run Puppet Apply, Restart Daemons, etc
我已经做了什么:
1)将custom_hooks所有者更改为git
2)将收件后文件所有者更改为git并使其可执行
3)改变了目标。文件夹所有者为git,并为此文件夹提供777权限
但是,当我试图提交时,没有任何事情发生