在gogs中給倉庫設置git鉤子要實現項目自動部署,但是鉤子設置後沒有起作用,查看gogs中的post-receive的log文件,顯示:
cat /home/gogs/log/hooks/post-receive.log
2020/04/14 14:17:40 [FATAL] [...its/gogs/cmd/hook.go:274 runHookPostReceive()] Fail to execute custom post-receive hook: exit status 128
2020/04/14 14:24:12 [FATAL] [...its/gogs/cmd/hook.go:274 runHookPostReceive()] Fail to execute custom post-receive hook: exit status 1
2020/04/14 14:31:24 [FATAL] [...its/gogs/cmd/hook.go:274 runHookPostReceive()] Fail to execute custom post-receive hook: exit status 1
post-receive鉤子文件內容如下:
#!/bin/bash
unset $(git rev-parse --local-env-vars);
cd /home/demo/
git pull origin master
翻看gogs的issues後發現其中有人給出將鉤子中的第一行做修改後即可正常運行,原因未知,修改後的文件如下:
#!/usr/bin/env bash
unset $(git rev-parse --local-env-vars);
cd /home/demo/
git pull origin master