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:
qwerty287
2022-05-18 23:25:14 +02:00
committed by GitHub
parent 0b2b776ed8
commit f05f918b8d
3 changed files with 39 additions and 20 deletions

View File

@@ -183,6 +183,7 @@ func (c *Compiler) Compile(conf *yaml.Config) *backend.Config {
config.Stages = append(config.Stages, stage)
}
var stages []*backend.Stage
// add pipeline steps. 1 pipeline step per stage, at the moment
var stage *backend.Stage
var group string
@@ -202,7 +203,7 @@ func (c *Compiler) Compile(conf *yaml.Config) *backend.Config {
stage = new(backend.Stage)
stage.Name = fmt.Sprintf("%s_stage_%v", c.prefix, i)
stage.Alias = container.Name
config.Stages = append(config.Stages, stage)
stages = append(stages, stage)
}
name := fmt.Sprintf("%s_step_%d", c.prefix, i)
@@ -210,6 +211,13 @@ func (c *Compiler) Compile(conf *yaml.Config) *backend.Config {
stage.Steps = append(stage.Steps, step)
}
if len(stages) == 0 {
// nothing will run, remove services and clone step
config.Stages = []*backend.Stage{}
} else {
config.Stages = append(config.Stages, stages...)
}
c.setupCacheRebuild(conf, config)
return config