diff --git a/plugin/remote/gitlab/gitlab.go b/plugin/remote/gitlab/gitlab.go index 86028e64..61423297 100644 --- a/plugin/remote/gitlab/gitlab.go +++ b/plugin/remote/gitlab/gitlab.go @@ -135,7 +135,7 @@ func (r *Gitlab) Activate(user *model.User, repo *model.Repo, link string) error // append the repo owner / name to the hook url since gitlab // doesn't send this detail in the post-commit hook - link += "&owner=" + repo.Owner + "&name=" + repo.Name + link += "?owner=" + repo.Owner + "&name=" + repo.Name // add the hook return client.AddProjectHook(path, link, true, false, true) diff --git a/server/handler/hook.go b/server/handler/hook.go index f3b18663..66735fce 100644 --- a/server/handler/hook.go +++ b/server/handler/hook.go @@ -25,7 +25,7 @@ import ( func PostHook(c web.C, w http.ResponseWriter, r *http.Request) { var ctx = context.FromC(c) var host = c.URLParams["host"] - var token = r.FormValue("token") + var token = c.URLParams["token"] var remote = remote.Lookup(host) if remote == nil { w.WriteHeader(http.StatusNotFound) diff --git a/server/handler/repo.go b/server/handler/repo.go index 54896b9f..be766243 100644 --- a/server/handler/repo.go +++ b/server/handler/repo.go @@ -99,7 +99,7 @@ func PostRepo(c web.C, w http.ResponseWriter, r *http.Request) { // setup the post-commit hook with the remote system and // if necessary, register the public key - var hook = fmt.Sprintf("%s/api/hook/%s?token=%s", httputil.GetURL(r), repo.Remote, repo.Token) + var hook = fmt.Sprintf("%s/api/hook/%s/%s", httputil.GetURL(r), repo.Remote, repo.Token) if err := remote.Activate(user, repo, hook); err != nil { w.WriteHeader(http.StatusInternalServerError) return diff --git a/server/router/router.go b/server/router/router.go index ec8bd40b..418256d1 100644 --- a/server/router/router.go +++ b/server/router/router.go @@ -15,9 +15,17 @@ func New() *web.Mux { mux.Post("/api/auth/:host", handler.GetLogin) mux.Get("/api/badge/:host/:owner/:name/status.svg", handler.GetBadge) mux.Get("/api/badge/:host/:owner/:name/cc.xml", handler.GetCC) + mux.Get("/api/hook/:host/:token", handler.PostHook) + mux.Put("/api/hook/:host/:token", handler.PostHook) + mux.Post("/api/hook/:host/:token", handler.PostHook) + + // these routes are here for backward compatibility + // to help people troubleshoot why their upgrade isn't + // working correctly. remove at some point mux.Get("/api/hook/:host", handler.PostHook) mux.Put("/api/hook/:host", handler.PostHook) mux.Post("/api/hook/:host", handler.PostHook) + //// streams := web.New() streams.Get("/api/stream/stdout/:id", handler.WsConsole)