mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2026-04-15 01:41:56 +00:00
Do not run clone step if no pipeline step will run (#877)
Skip the clone step and ignore hook/pipeline if no pipeline step except clone would run. The status reported back to the forge is `success`. Closes https://github.com/woodpecker-ci/woodpecker/issues/778
This commit is contained in:
@@ -200,10 +200,20 @@ func PostHook(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if zeroSteps(build, remoteYamlConfigs) {
|
||||
// TODO: move global pipeline filters into own check functions ...
|
||||
if z, steps := zeroSteps(build, remoteYamlConfigs); z {
|
||||
msg := "ignoring hook: step conditions yield zero runnable steps"
|
||||
log.Debug().Str("repo", repo.FullName).Msg(msg)
|
||||
c.String(http.StatusOK, msg)
|
||||
build.Status = model.StatusSuccess
|
||||
for _, step := range steps {
|
||||
step.Proc.State = model.StatusSuccess
|
||||
build.Procs = append(build.Procs, step.Proc)
|
||||
}
|
||||
// TODO: this wont create any builds the status can link to ...
|
||||
if err := updateBuildStatus(c, build, repo, repoUser); err != nil {
|
||||
log.Error().Err(err).Msg("updateBuildStatus")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -292,7 +302,7 @@ func branchFiltered(build *model.Build, remoteYamlConfigs []*remote.FileMeta) (b
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func zeroSteps(build *model.Build, remoteYamlConfigs []*remote.FileMeta) bool {
|
||||
func zeroSteps(build *model.Build, remoteYamlConfigs []*remote.FileMeta) (bool, []*shared.BuildItem) {
|
||||
b := shared.ProcBuilder{
|
||||
Repo: &model.Repo{},
|
||||
Curr: build,
|
||||
@@ -304,15 +314,16 @@ func zeroSteps(build *model.Build, remoteYamlConfigs []*remote.FileMeta) bool {
|
||||
Yamls: remoteYamlConfigs,
|
||||
}
|
||||
|
||||
buildItemsNoEmpty, err := b.Build()
|
||||
if err != nil {
|
||||
return false, []*shared.BuildItem{}
|
||||
}
|
||||
b.IncludeEmpty = true
|
||||
buildItems, err := b.Build()
|
||||
if err != nil {
|
||||
return false
|
||||
return false, []*shared.BuildItem{}
|
||||
}
|
||||
if len(buildItems) == 0 {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
return len(buildItemsNoEmpty) == 0, buildItems
|
||||
}
|
||||
|
||||
func findOrPersistPipelineConfig(store store.Store, build *model.Build, remoteYamlConfig *remote.FileMeta) (*model.Config, error) {
|
||||
|
||||
Reference in New Issue
Block a user