简体   繁体   中英

post-commit hook not running after commit

i have created a simple post-commit script:

#!/bin/bash

# Update server when any user commit some changes
# This ssh connection execute a script with sudo that pull git server repo

ssh -i /var/opt/gitlab/.ssh/git_new git@ipaddress "sudo /home/git/pull.sh"
echo "Finished hook execution" >> /tmp/hook_log.txt

the script is located at this path /var/opt/gitlab/git-data/repositories/systems/repo.git/hooks

and have 777 permisions temporary.

Im using the "Source Tree software" to commit an push my local code to our GitLab on premise website.

the problem is that when im running that script manually from shell everything works but not when im doing a commit--push througth the Source Tree Software.

how can i search in log files if the post-commit script is called by git after commit?

I am doing something wrong?

thanks in advance.

Regards.

i have experienced that the hook process that was running is post-receive in:

/opt/gitlab/embedded/service/gitlab-shell/hooks

there is a template with ruby code and i have added this:

    #!/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.
# You can add your own hooks to this file, but be careful when updating gitlab-shell!

exec 'echo "pulling from repo" && ssh -i /var/opt/gitlab/.ssh/git_new  git@ipaddress "sudo /home/git/pull.sh"'

changes = ARGF.read
key_id  = ENV['GL_ID']
repo_path = Dir.pwd

require_relative '../lib/gitlab_post_receive'

if GitlabPostReceive.new(repo_path, key_id, changes).exec
  exit 0
else
  exit 1
End

after this the changes made from sourcetree, git command or website execute the batch successfully.

thanks.

Regards.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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