diff --git a/server/api/hook.go b/server/api/hook.go index 3fca729696d..af1ad0fae5f 100644 --- a/server/api/hook.go +++ b/server/api/hook.go @@ -108,7 +108,7 @@ func PostHook(c *gin.Context) { _store := store.FromContext(c) forge := server.Config.Services.Forge - tmpRepo, tmpBuild, err := forge.Hook(c, c.Request) + tmpRepo, tmpPipeline, err := forge.Hook(c, c.Request) if err != nil { if errors.Is(err, &types.ErrIgnoreEvent{}) { msg := fmt.Sprintf("forge driver: %s", err) @@ -123,7 +123,7 @@ func PostHook(c *gin.Context) { return } - if tmpBuild == nil { + if tmpPipeline == nil { msg := "ignoring hook: hook parsing resulted in empty pipeline" log.Debug().Msg(msg) c.String(http.StatusOK, msg) @@ -136,11 +136,11 @@ func PostHook(c *gin.Context) { return } - // skip the tmpBuild if any case-insensitive combination of the words "skip" and "ci" + // skip the tmpPipeline if any case-insensitive combination of the words "skip" and "ci" // wrapped in square brackets appear in the commit message - skipMatch := skipRe.FindString(tmpBuild.Message) + skipMatch := skipRe.FindString(tmpPipeline.Message) if len(skipMatch) > 0 { - msg := fmt.Sprintf("ignoring hook: %s found in %s", skipMatch, tmpBuild.Commit) + msg := fmt.Sprintf("ignoring hook: %s found in %s", skipMatch, tmpPipeline.Commit) log.Debug().Msg(msg) c.String(http.StatusNoContent, msg) return @@ -212,14 +212,14 @@ func PostHook(c *gin.Context) { return } - if tmpBuild.Event == model.EventPull && !repo.AllowPull { + if tmpPipeline.Event == model.EventPull && !repo.AllowPull { msg := "ignoring hook: pull requests are disabled for this repo in woodpecker" log.Debug().Str("repo", repo.FullName).Msg(msg) c.String(http.StatusNoContent, msg) return } - pl, err := pipeline.Create(c, _store, repo, tmpBuild) + pl, err := pipeline.Create(c, _store, repo, tmpPipeline) if err != nil { handlePipelineErr(c, err) } else { diff --git a/server/api/repo.go b/server/api/repo.go index ea4425ab1d7..6ca9b64360a 100644 --- a/server/api/repo.go +++ b/server/api/repo.go @@ -114,7 +114,7 @@ func PostRepo(c *gin.Context) { } link := fmt.Sprintf( - "%s/hook?access_token=%s", + "%s/api/hook?access_token=%s", server.Config.Server.WebhookHost, sig, ) @@ -437,7 +437,7 @@ func RepairRepo(c *gin.Context) { // reconstruct the link host := server.Config.Server.Host link := fmt.Sprintf( - "%s/hook?access_token=%s", + "%s/api/hook?access_token=%s", host, sig, ) @@ -551,7 +551,7 @@ func MoveRepo(c *gin.Context) { // reconstruct the link host := server.Config.Server.Host link := fmt.Sprintf( - "%s/hook?access_token=%s", + "%s/api/hook?access_token=%s", host, sig, ) diff --git a/server/router/api.go b/server/router/api.go index 9517fca1142..e22dc3b8cc7 100644 --- a/server/router/api.go +++ b/server/router/api.go @@ -194,6 +194,7 @@ func apiRoutes(e *gin.RouterGroup) { session.SetPerm(), session.MustPull, api.LogStreamSSE) + stream.GET("/events", api.EventStreamSSE) } if zerolog.GlobalLevel() <= zerolog.DebugLevel { diff --git a/web/src/lib/api/index.ts b/web/src/lib/api/index.ts index a41479cc4a2..68f03fdc061 100644 --- a/web/src/lib/api/index.ts +++ b/web/src/lib/api/index.ts @@ -305,7 +305,7 @@ export default class WoodpeckerClient extends ApiClient { // eslint-disable-next-line promise/prefer-await-to-callbacks on(callback: (data: { pipeline?: Pipeline; repo?: Repo; step?: PipelineWorkflow }) => void): EventSource { - return this._subscribe('/stream/events', callback, { + return this._subscribe('/api/stream/events', callback, { reconnect: true, }); }