diff --git a/engine/api/workflow/hook.go b/engine/api/workflow/hook.go index c277420c26..99fd3ac8ee 100644 --- a/engine/api/workflow/hook.go +++ b/engine/api/workflow/hook.go @@ -299,10 +299,6 @@ func DefaultPayload(ctx context.Context, db gorp.SqlExecutor, store cache.Store, return nil, nil } - if wf.Root.Context.Application == nil { - return wf.Root.Context.DefaultPayload, nil - } - var defaultPayload interface{} // Load application if not available if wf.Root.Context != nil && wf.Root.Context.Application == nil && wf.Root.Context.ApplicationID != 0 { @@ -313,6 +309,10 @@ func DefaultPayload(ctx context.Context, db gorp.SqlExecutor, store cache.Store, wf.Root.Context.Application = app } + if wf.Root.Context.Application == nil { + return wf.Root.Context.DefaultPayload, nil + } + if wf.Root.Context.Application.RepositoryFullname != "" { defaultBranch := "master" projectVCSServer := repositoriesmanager.GetProjectVCSServer(p, wf.Root.Context.Application.VCSServer)