Git middleware issues

Hello,
I have some issues using the git middleware, more specifically the webhook part of it.
I have the source of the site hosted in a gogs instance, my Caddyfile part is as follows:

https://mysite {
        gzip
        log stdout
        errors stderr
        tls user@mysite
git {
        repo http://someuser:password@git.mysite/www.git
        path    ../../git/www
        hook /webhook
        then /usr/bin/builder www
        }

        root /srv/html/www
}

when starting caddy git pulls and the builder script is launched.
if there is no /webhook file or directory a git push will trigger a POST but caddy will respond with 404
if I create a directory /webhook, git push will trigger a POST but caddy will respond with 404
if I create a file /webhook, git push will trigger a POST and caddy will respond with 200 but neither will do a git pull nor launch the builder script.
Any idea what I am doing wrong? documentation does ot say anything about the existence or not of a physical webhook endpoint.

This should not be required but try adding hook_type gogs to the git config and see if anything changes.

It is preferred to not have a webhook endpoint point to a valid file/directory. I am not sure of the behaviour yet as I have not tested the scenario.

Lastly, enable access log log and monitor the requests.

Caddyfile:

https… {
gzip
log stdout
errors stderr
tls user@mysite
git {
repo ht…
path …/…/git/www
hook /webhook
hook_type gogs
then /usr/bin/builder www
}

root /srv/html/www

}

log:
2016/06/15 10:22:43 Caddyfile:10 - Parse error: invalid hook type gogs

if I delete the physical endpoint files I get in log:
[15/Jun/2016:10:49:39 +0200] “POST /webhook HTTP/1.1” 404 38

gogs says failure and the response it sees is:

Headers:
Content-Type: text/plain; charset=utf-8
Date: Wed, 15 Jun 2016 08:49:39 GMT
Server: Caddy
Vary: Accept-Encoding
X-Content-Type-Options: nosniff
Body:
404 Not Found
Gogs request was:
Headers:
Request URL: https…webhook
Request method: POST
Content-Type: application/json
X-Gogs-Delivery: e8dbf53c-2ad1-4239-a9a9-9b37780c08b3
X-Gogs-Event: push

Sorry but I had to edit the URLs :confused:

This should not happen. What version of Caddy are you running ?

caddy --version
Caddy 0.8.3
downloaded from caddyserver.com with git feature

I haven’t updated the build server recently since I’ve been working so much on 0.9. Could that be the issue?

The current version works fine too. No similar issues have been reported before.

It seems to me that the git module does not even execute pull hourly. As far as I can see it only pulls at caddy startup.

That only works when webhook is not used. Either interval or webhook.

What seems strange to me is that it errors on hook_type gogs, for that I have no explanation.

Actually, that was mainly introduced as a security measure for generic hook type. Hook types are auto detected and should work fine.

I added tests here because of your issue and it passed. Mind trying 0.9 beta ?

Sure I can try 0.9 beta, but on that server I have no go environment, is there somewhere a 0.9 built with git feature for linux amd64?

Do you have a local Go environment you can build it on? Build server is still on 0.8x

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.