mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-09-19 21:03:13 +00:00
Auto cancel blocked pipelines (#905)
This commit is contained in:
@@ -295,19 +295,15 @@ func cancelBuild(
|
|||||||
return http.StatusInternalServerError, err
|
return http.StatusInternalServerError, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// For pending builds, we stream the UI the latest state.
|
procs, err = _store.ProcList(killedBuild)
|
||||||
// For running builds, the UI will be updated when the agents acknowledge the cancel
|
if err != nil {
|
||||||
if build.Status == model.StatusPending {
|
return http.StatusNotFound, err
|
||||||
procs, err = _store.ProcList(killedBuild)
|
}
|
||||||
if err != nil {
|
if killedBuild.Procs, err = model.Tree(procs); err != nil {
|
||||||
return http.StatusNotFound, err
|
return http.StatusInternalServerError, err
|
||||||
}
|
}
|
||||||
if killedBuild.Procs, err = model.Tree(procs); err != nil {
|
if err := publishToTopic(ctx, killedBuild, repo); err != nil {
|
||||||
return http.StatusInternalServerError, err
|
log.Error().Err(err).Msg("publishToTopic")
|
||||||
}
|
|
||||||
if err := publishToTopic(ctx, killedBuild, repo); err != nil {
|
|
||||||
log.Error().Err(err).Msg("publishToTopic")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return http.StatusNoContent, nil
|
return http.StatusNoContent, nil
|
||||||
|
@@ -80,11 +80,12 @@ func (s storage) GetBuildList(repo *model.Repo, page int) ([]*model.Build, error
|
|||||||
Find(&builds)
|
Find(&builds)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetActiveBuildList get all builds that are pending, running or blocked
|
||||||
func (s storage) GetActiveBuildList(repo *model.Repo, page int) ([]*model.Build, error) {
|
func (s storage) GetActiveBuildList(repo *model.Repo, page int) ([]*model.Build, error) {
|
||||||
builds := make([]*model.Build, 0, perPage)
|
builds := make([]*model.Build, 0, perPage)
|
||||||
query := s.engine.
|
query := s.engine.
|
||||||
Where("build_repo_id = ?", repo.ID).
|
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")
|
Desc("build_number")
|
||||||
if page > 0 {
|
if page > 0 {
|
||||||
query = query.Limit(perPage, perPage*(page-1))
|
query = query.Limit(perPage, perPage*(page-1))
|
||||||
|
Reference in New Issue
Block a user