diff --git a/api-docs.yml b/api-docs.yml index b9253dfa..416c1afc 100644 --- a/api-docs.yml +++ b/api-docs.yml @@ -774,6 +774,10 @@ definitions: type: integer template_id: type: integer + name: + type: string + disabled: + type: boolean Schedule: type: object @@ -786,6 +790,10 @@ definitions: type: integer template_id: type: integer + name: + type: string + disabled: + type: boolean ViewRequest: type: object diff --git a/db/Schedule.go b/db/Schedule.go index 30194a7b..27f499f2 100644 --- a/db/Schedule.go +++ b/db/Schedule.go @@ -1,12 +1,15 @@ package db type Schedule struct { - ID int `db:"id" json:"id"` - ProjectID int `db:"project_id" json:"project_id"` - TemplateID int `db:"template_id" json:"template_id"` - CronFormat string `db:"cron_format" json:"cron_format"` - RepositoryID *int `db:"repository_id" json:"repository_id"` + ID int `db:"id" json:"id"` + ProjectID int `db:"project_id" json:"project_id"` + TemplateID int `db:"template_id" json:"template_id"` + CronFormat string `db:"cron_format" json:"cron_format"` + Name string `db:"name" json:"name"` + Disabled bool `db:"disabled" json:"disabled"` + LastCommitHash *string `db:"last_commit_hash" json:"-"` + RepositoryID *int `db:"repository_id" json:"repository_id"` } type ScheduleWithTpl struct { diff --git a/db/sql/migrations/v2.10.11.sql b/db/sql/migrations/v2.10.11.sql index c58df2bd..e2568e92 100644 --- a/db/sql/migrations/v2.10.11.sql +++ b/db/sql/migrations/v2.10.11.sql @@ -1 +1,3 @@ -alter table `project__template` add `tasks` int not null default 0; \ No newline at end of file +alter table `project__template` add `tasks` int not null default 0; +alter table `project__schedule` add `name` varchar(100); +alter table `project__schedule` add `disabled` boolean not null default false; \ No newline at end of file diff --git a/services/schedules/SchedulePool.go b/services/schedules/SchedulePool.go index 5c4b2a0f..dcdefe27 100644 --- a/services/schedules/SchedulePool.go +++ b/services/schedules/SchedulePool.go @@ -4,11 +4,11 @@ import ( "strconv" "sync" - log "github.com/sirupsen/logrus" "github.com/ansible-semaphore/semaphore/db" "github.com/ansible-semaphore/semaphore/db_lib" "github.com/ansible-semaphore/semaphore/services/tasks" "github.com/robfig/cron/v3" + log "github.com/sirupsen/logrus" ) type ScheduleRunner struct { @@ -111,6 +111,10 @@ func (p *SchedulePool) Refresh() { p.locker.Lock() p.clear() for _, schedule := range schedules { + if schedule.Disabled { + continue + } + _, err := p.addRunner(ScheduleRunner{ projectID: schedule.ProjectID, scheduleID: schedule.ID,