mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-01-10 17:45:36 +00:00
Auto cancel blocked pipelines (#905)
This commit is contained in:
parent
7313de2b1d
commit
bdb007e064
2 changed files with 11 additions and 14 deletions
|
@ -295,19 +295,15 @@ func cancelBuild(
|
|||
return http.StatusInternalServerError, err
|
||||
}
|
||||
|
||||
// For pending builds, we stream the UI the latest state.
|
||||
// For running builds, the UI will be updated when the agents acknowledge the cancel
|
||||
if build.Status == model.StatusPending {
|
||||
procs, err = _store.ProcList(killedBuild)
|
||||
if err != nil {
|
||||
return http.StatusNotFound, err
|
||||
}
|
||||
if killedBuild.Procs, err = model.Tree(procs); err != nil {
|
||||
return http.StatusInternalServerError, err
|
||||
}
|
||||
if err := publishToTopic(ctx, killedBuild, repo); err != nil {
|
||||
log.Error().Err(err).Msg("publishToTopic")
|
||||
}
|
||||
procs, err = _store.ProcList(killedBuild)
|
||||
if err != nil {
|
||||
return http.StatusNotFound, err
|
||||
}
|
||||
if killedBuild.Procs, err = model.Tree(procs); err != nil {
|
||||
return http.StatusInternalServerError, err
|
||||
}
|
||||
if err := publishToTopic(ctx, killedBuild, repo); err != nil {
|
||||
log.Error().Err(err).Msg("publishToTopic")
|
||||
}
|
||||
|
||||
return http.StatusNoContent, nil
|
||||
|
|
|
@ -80,11 +80,12 @@ func (s storage) GetBuildList(repo *model.Repo, page int) ([]*model.Build, error
|
|||
Find(&builds)
|
||||
}
|
||||
|
||||
// GetActiveBuildList get all builds that are pending, running or blocked
|
||||
func (s storage) GetActiveBuildList(repo *model.Repo, page int) ([]*model.Build, error) {
|
||||
builds := make([]*model.Build, 0, perPage)
|
||||
query := s.engine.
|
||||
Where("build_repo_id = ?", repo.ID).
|
||||
Where("build_status = ? or build_status = ?", "pending", "running").
|
||||
In("build_status", model.StatusPending, model.StatusRunning, model.StatusBlocked).
|
||||
Desc("build_number")
|
||||
if page > 0 {
|
||||
query = query.Limit(perPage, perPage*(page-1))
|
||||
|
|
Loading…
Reference in a new issue