在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