mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-09-28 14:31:59 +00:00
Moved things closer that belong together
This commit is contained in:
parent
ddabcde3e3
commit
4cce34d5bf
1 changed files with 13 additions and 18 deletions
|
@ -157,13 +157,7 @@ func PostHook(c *gin.Context) {
|
||||||
}
|
}
|
||||||
build.ConfigID = conf.ID
|
build.ConfigID = conf.ID
|
||||||
|
|
||||||
netrc, err := remote_.Netrc(user, repo)
|
// verify that pipeline can be built at all
|
||||||
if err != nil {
|
|
||||||
c.String(500, "Failed to generate netrc file. %s", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// verify the branches can be built vs skipped
|
|
||||||
parsedPipelineConfig, err := yaml.ParseString(conf.Data)
|
parsedPipelineConfig, err := yaml.ParseString(conf.Data)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if !parsedPipelineConfig.Branches.Match(build.Branch) && build.Event != model.EventTag && build.Event != model.EventDeploy {
|
if !parsedPipelineConfig.Branches.Match(build.Branch) && build.Event != model.EventTag && build.Event != model.EventDeploy {
|
||||||
|
@ -172,11 +166,6 @@ func PostHook(c *gin.Context) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// update some build fields
|
|
||||||
build.RepoID = repo.ID
|
|
||||||
build.Verified = true
|
|
||||||
build.Status = model.StatusPending
|
|
||||||
|
|
||||||
if repo.IsGated {
|
if repo.IsGated {
|
||||||
allowed, _ := Config.Services.Senders.SenderAllowed(user, repo, build, conf)
|
allowed, _ := Config.Services.Senders.SenderAllowed(user, repo, build, conf)
|
||||||
if !allowed {
|
if !allowed {
|
||||||
|
@ -184,6 +173,11 @@ func PostHook(c *gin.Context) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// update some build fields
|
||||||
|
build.RepoID = repo.ID
|
||||||
|
build.Verified = true
|
||||||
|
build.Status = model.StatusPending
|
||||||
|
|
||||||
err = store.CreateBuild(c, build, build.Procs...)
|
err = store.CreateBuild(c, build, build.Procs...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Errorf("failure to save commit for %s. %s", repo.FullName, err)
|
logrus.Errorf("failure to save commit for %s. %s", repo.FullName, err)
|
||||||
|
@ -197,6 +191,12 @@ func PostHook(c *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
netrc, err := remote_.Netrc(user, repo)
|
||||||
|
if err != nil {
|
||||||
|
c.String(500, "Failed to generate netrc file. %s", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
envs := map[string]string{}
|
envs := map[string]string{}
|
||||||
if Config.Services.Environ != nil {
|
if Config.Services.Environ != nil {
|
||||||
globals, _ := Config.Services.Environ.EnvironList(repo)
|
globals, _ := Config.Services.Environ.EnvironList(repo)
|
||||||
|
@ -215,14 +215,9 @@ func PostHook(c *gin.Context) {
|
||||||
logrus.Debugf("Error getting registry credentials for %s#%d. %s", repo.FullName, build.Number, err)
|
logrus.Debugf("Error getting registry credentials for %s#%d. %s", repo.FullName, build.Number, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the previous build so that we can send
|
// get the previous build so that we can send status change notifications
|
||||||
// on status change notifications
|
|
||||||
last, _ := store.GetBuildLastBefore(c, repo, build.Branch, build.ID)
|
last, _ := store.GetBuildLastBefore(c, repo, build.Branch, build.ID)
|
||||||
|
|
||||||
//
|
|
||||||
// BELOW: NEW
|
|
||||||
//
|
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
uri := fmt.Sprintf("%s/%s/%d", httputil.GetURL(c.Request), repo.FullName, build.Number)
|
uri := fmt.Sprintf("%s/%s/%d", httputil.GetURL(c.Request), repo.FullName, build.Number)
|
||||||
err = remote_.Status(user, repo, build, uri)
|
err = remote_.Status(user, repo, build, uri)
|
||||||
|
|
Loading…
Reference in a new issue