mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-18 07:54:28 +00:00
Merge pull request #67 from laszlocph/surface-parsing-errors
Surface parsing error in branch filter
This commit is contained in:
commit
45877a7a82
1 changed files with 15 additions and 8 deletions
|
@ -172,7 +172,12 @@ func PostHook(c *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if branchFiltered(build, remoteYamlConfigs) {
|
filtered, err := branchFiltered(build, remoteYamlConfigs)
|
||||||
|
if err != nil {
|
||||||
|
logrus.Errorf("failure to parse yaml from hook for %s. %s", repo.FullName, err)
|
||||||
|
c.AbortWithError(400, err)
|
||||||
|
}
|
||||||
|
if filtered {
|
||||||
c.String(200, "Branch does not match restrictions defined in yaml")
|
c.String(200, "Branch does not match restrictions defined in yaml")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -286,17 +291,19 @@ func PostHook(c *gin.Context) {
|
||||||
queueBuild(build, repo, buildItems)
|
queueBuild(build, repo, buildItems)
|
||||||
}
|
}
|
||||||
|
|
||||||
func branchFiltered(build *model.Build, remoteYamlConfigs []*remote.FileMeta) bool {
|
func branchFiltered(build *model.Build, remoteYamlConfigs []*remote.FileMeta) (bool, error) {
|
||||||
for _, remoteYamlConfig := range remoteYamlConfigs {
|
for _, remoteYamlConfig := range remoteYamlConfigs {
|
||||||
parsedPipelineConfig, err := yaml.ParseString(string(remoteYamlConfig.Data))
|
parsedPipelineConfig, err := yaml.ParseString(string(remoteYamlConfig.Data))
|
||||||
if err == nil {
|
if err != nil {
|
||||||
if !parsedPipelineConfig.Branches.Match(build.Branch) && build.Event != model.EventTag && build.Event != model.EventDeploy {
|
return false, err
|
||||||
} else {
|
}
|
||||||
return false
|
|
||||||
}
|
if !parsedPipelineConfig.Branches.Match(build.Branch) && build.Event != model.EventTag && build.Event != model.EventDeploy {
|
||||||
|
} else {
|
||||||
|
return false, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func zeroSteps(build *model.Build, remoteYamlConfigs []*remote.FileMeta) bool {
|
func zeroSteps(build *model.Build, remoteYamlConfigs []*remote.FileMeta) bool {
|
||||||
|
|
Loading…
Reference in a new issue