Skip to content

Commit acb9fc5

Browse files
zeripathnoerw
andauthored
Make cron task no notice on success (#19221)
Change all cron tasks to make them no notice on success default. Instead if a user wants notices on success they need to add NOTICE_ON_SUCCESS=true instead. ## ⚠️ BREAKING ⚠️ This changes the cron config so that notices on success are no longer set by default and breaks NO_SUCCESS_NOTICE settings. Instead users who want notices on success must set NOTICE_ON_SUCCESS=true instead. Signed-off-by: Andrew Thornton <[email protected]> * Update custom/conf/app.example.ini Co-authored-by: Norwin <[email protected]> Co-authored-by: Norwin <[email protected]>
1 parent 70628bd commit acb9fc5

File tree

4 files changed

+30
-32
lines changed

4 files changed

+30
-32
lines changed

custom/conf/app.example.ini

+17-17
Original file line numberDiff line numberDiff line change
@@ -1752,8 +1752,8 @@ PATH =
17521752
;ENABLED = true
17531753
;; Whether to always run at least once at start up time (if ENABLED)
17541754
;RUN_AT_START = true
1755-
;; Notice if not success
1756-
;NO_SUCCESS_NOTICE = false
1755+
;; Whether to emit notice on successful execution too
1756+
;NOTICE_ON_SUCCESS = false
17571757
;; Time interval for job to run
17581758
;SCHEDULE = @midnight
17591759
;; Archives created more than OLDER_THAN ago are subject to deletion
@@ -1772,7 +1772,7 @@ PATH =
17721772
;; Run Update mirrors task when Gitea starts.
17731773
;RUN_AT_START = false
17741774
;; Notice if not success
1775-
;NO_SUCCESS_NOTICE = true
1775+
;NOTICE_ON_SUCCESS = false
17761776
;; Limit the number of mirrors added to the queue to this number
17771777
;; (negative values mean no limit, 0 will result in no result in no mirrors being queued effectively disabling pull mirror updating.)
17781778
;PULL_LIMIT=50
@@ -1793,7 +1793,7 @@ PATH =
17931793
;; Run Repository health check task when Gitea starts.
17941794
;RUN_AT_START = false
17951795
;; Notice if not success
1796-
;NO_SUCCESS_NOTICE = false
1796+
;NOTICE_ON_SUCCESS = false
17971797
;TIMEOUT = 60s
17981798
;; Arguments for command 'git fsck', e.g. "--unreachable --tags"
17991799
;; see more on http://git-scm.com/docs/git-fsck
@@ -1811,7 +1811,7 @@ PATH =
18111811
;; Run check repository statistics task when Gitea starts.
18121812
;RUN_AT_START = true
18131813
;; Notice if not success
1814-
;NO_SUCCESS_NOTICE = false
1814+
;NOTICE_ON_SUCCESS = false
18151815
;SCHEDULE = @midnight
18161816

18171817
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -1824,7 +1824,7 @@ PATH =
18241824
;; Update migrated repositories' issues and comments' posterid when starting server (default true)
18251825
;RUN_AT_START = true
18261826
;; Notice if not success
1827-
;NO_SUCCESS_NOTICE = false
1827+
;NOTICE_ON_SUCCESS = false
18281828
;; Interval as a duration between each synchronization. (default every 24h)
18291829
;SCHEDULE = @midnight
18301830

@@ -1839,7 +1839,7 @@ PATH =
18391839
;; Synchronize external user data when starting server (default false)
18401840
;RUN_AT_START = false
18411841
;; Notice if not success
1842-
;NO_SUCCESS_NOTICE = false
1842+
;NOTICE_ON_SUCCESS = false
18431843
;; Interval as a duration between each synchronization (default every 24h)
18441844
;SCHEDULE = @midnight
18451845
;; Create new users, update existing user data and disable users that are not in external source anymore (default)
@@ -1857,7 +1857,7 @@ PATH =
18571857
;; Clean-up deleted branches when starting server (default true)
18581858
;RUN_AT_START = true
18591859
;; Notice if not success
1860-
;NO_SUCCESS_NOTICE = false
1860+
;NOTICE_ON_SUCCESS = false
18611861
;; Interval as a duration between each synchronization (default every 24h)
18621862
;SCHEDULE = @midnight
18631863
;; deleted branches than OLDER_THAN ago are subject to deletion
@@ -1900,7 +1900,7 @@ PATH =
19001900
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
19011901
;ENABLED = false
19021902
;RUN_AT_START = false
1903-
;NO_SUCCESS_NOTICE = false
1903+
;NOTICE_ON_SUCCESS = false
19041904
;SCHEDULE = @annually
19051905
;OLDER_THAN = 168h
19061906

@@ -1913,7 +1913,7 @@ PATH =
19131913
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
19141914
;ENABLED = false
19151915
;RUN_AT_START = false
1916-
;NO_SUCCESS_NOTICE = false
1916+
;NOTICE_ON_SUCCESS = false
19171917
;SCHEDULE = @annually;
19181918

19191919
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -1925,7 +1925,7 @@ PATH =
19251925
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
19261926
;ENABLED = false
19271927
;RUN_AT_START = false
1928-
;NO_SUCCESS_NOTICE = false
1928+
;NOTICE_ON_SUCCESS = false
19291929
;SCHEDULE = @every 72h
19301930
;TIMEOUT = 60s
19311931
;; Arguments for command 'git gc'
@@ -1941,7 +1941,7 @@ PATH =
19411941
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
19421942
;ENABLED = false
19431943
;RUN_AT_START = false
1944-
;NO_SUCCESS_NOTICE = false
1944+
;NOTICE_ON_SUCCESS = false
19451945
;SCHEDULE = @every 72h
19461946

19471947
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -1953,7 +1953,7 @@ PATH =
19531953
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
19541954
;ENABLED = false
19551955
;RUN_AT_START = false
1956-
;NO_SUCCESS_NOTICE = false
1956+
;NOTICE_ON_SUCCESS = false
19571957
;SCHEDULE = @every 72h
19581958

19591959
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -1965,7 +1965,7 @@ PATH =
19651965
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
19661966
;ENABLED = false
19671967
;RUN_AT_START = false
1968-
;NO_SUCCESS_NOTICE = false
1968+
;NOTICE_ON_SUCCESS = false
19691969
;SCHEDULE = @every 72h
19701970

19711971
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -1977,7 +1977,7 @@ PATH =
19771977
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
19781978
;ENABLED = false
19791979
;RUN_AT_START = false
1980-
;NO_SUCCESS_NOTICE = false
1980+
;NOTICE_ON_SUCCESS = false
19811981
;SCHEDULE = @every 72h
19821982

19831983
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -1989,7 +1989,7 @@ PATH =
19891989
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
19901990
;ENABLED = false
19911991
;RUN_AT_START = false
1992-
;NO_SUCCESS_NOTICE = false
1992+
;NOTICE_ON_SUCCESS = false
19931993
;SCHEDULE = @every 72h
19941994

19951995
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -2001,7 +2001,7 @@ PATH =
20012001
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
20022002
;ENABLED = false
20032003
;RUN_AT_START = false
2004-
;NO_SUCCESS_NOTICE = false
2004+
;NOTICE_ON_SUCCESS = false
20052005
;SCHEDULE = @every 168h
20062006
;OLDER_THAN = 8760h
20072007

docs/content/doc/advanced/config-cheat-sheet.en-us.md

+8-9
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ Default templates for project boards:
816816

817817
- `ENABLED`: **false**: Enable to run all cron tasks periodically with default settings.
818818
- `RUN_AT_START`: **false**: Run cron tasks at application start-up.
819-
- `NO_SUCCESS_NOTICE`: **false**: Set to true to switch off success notices.
819+
- `NOTICE_ON_SUCCESS`: **false**: Set to true to switch on success notices.
820820

821821
- `SCHEDULE` accept formats
822822
- Full crontab specs, e.g. `* * * * * ?`
@@ -835,7 +835,6 @@ Default templates for project boards:
835835
#### Cron - Update Mirrors (`cron.update_mirrors`)
836836

837837
- `SCHEDULE`: **@every 10m**: Cron syntax for scheduling update mirrors, e.g. `@every 3h`.
838-
- `NO_SUCCESS_NOTICE`: **true**: The cron task for update mirrors success report is not very useful - as it just means that the mirrors have been queued. Therefore this is turned off by default.
839838
- `PULL_LIMIT`: **50**: Limit the number of mirrors added to the queue to this number (negative values mean no limit, 0 will result in no mirrors being queued effectively disabling pull mirror updating).
840839
- `PUSH_LIMIT`: **50**: Limit the number of mirrors added to the queue to this number (negative values mean no limit, 0 will result in no mirrors being queued effectively disabling push mirror updating).
841840

@@ -875,43 +874,43 @@ Default templates for project boards:
875874
- `RUN_AT_START`: **false**: Run tasks at start up time (if ENABLED).
876875
- `SCHEDULE`: **@every 72h**: Cron syntax for scheduling repository archive cleanup, e.g. `@every 1h`.
877876
- `TIMEOUT`: **60s**: Time duration syntax for garbage collection execution timeout.
878-
- `NO_SUCCESS_NOTICE`: **false**: Set to true to switch off success notices.
877+
- `NOTICE_ON_SUCCESS`: **false**: Set to true to switch on success notices.
879878
- `ARGS`: **\<empty\>**: Arguments for command `git gc`, e.g. `--aggressive --auto`. The default value is same with [git] -> GC_ARGS
880879

881880
#### Cron - Update the '.ssh/authorized_keys' file with Gitea SSH keys ('cron.resync_all_sshkeys')
882881
- `ENABLED`: **false**: Enable service.
883882
- `RUN_AT_START`: **false**: Run tasks at start up time (if ENABLED).
884-
- `NO_SUCCESS_NOTICE`: **false**: Set to true to switch off success notices.
883+
- `NOTICE_ON_SUCCESS`: **false**: Set to true to switch on success notices.
885884
- `SCHEDULE`: **@every 72h**: Cron syntax for scheduling repository archive cleanup, e.g. `@every 1h`.
886885

887886
#### Cron - Resynchronize pre-receive, update and post-receive hooks of all repositories ('cron.resync_all_hooks')
888887
- `ENABLED`: **false**: Enable service.
889888
- `RUN_AT_START`: **false**: Run tasks at start up time (if ENABLED).
890-
- `NO_SUCCESS_NOTICE`: **false**: Set to true to switch off success notices.
889+
- `NOTICE_ON_SUCCESS`: **false**: Set to true to switch on success notices.
891890
- `SCHEDULE`: **@every 72h**: Cron syntax for scheduling repository archive cleanup, e.g. `@every 1h`.
892891

893892
#### Cron - Reinitialize all missing Git repositories for which records exist ('cron.reinit_missing_repos')
894893
- `ENABLED`: **false**: Enable service.
895894
- `RUN_AT_START`: **false**: Run tasks at start up time (if ENABLED).
896-
- `NO_SUCCESS_NOTICE`: **false**: Set to true to switch off success notices.
895+
- `NOTICE_ON_SUCCESS`: **false**: Set to true to switch on success notices.
897896
- `SCHEDULE`: **@every 72h**: Cron syntax for scheduling repository archive cleanup, e.g. `@every 1h`.
898897

899898
#### Cron - Delete all repositories missing their Git files ('cron.delete_missing_repos')
900899
- `ENABLED`: **false**: Enable service.
901900
- `RUN_AT_START`: **false**: Run tasks at start up time (if ENABLED).
902-
- `NO_SUCCESS_NOTICE`: **false**: Set to true to switch off success notices.
901+
- `NOTICE_ON_SUCCESS`: **false**: Set to true to switch on success notices.
903902
- `SCHEDULE`: **@every 72h**: Cron syntax for scheduling repository archive cleanup, e.g. `@every 1h`.
904903

905904
#### Cron - Delete generated repository avatars ('cron.delete_generated_repository_avatars')
906905
- `ENABLED`: **false**: Enable service.
907906
- `RUN_AT_START`: **false**: Run tasks at start up time (if ENABLED).
908-
- `NO_SUCCESS_NOTICE`: **false**: Set to true to switch off success notices.
907+
- `NOTICE_ON_SUCCESS`: **false**: Set to true to switch on success notices.
909908
- `SCHEDULE`: **@every 72h**: Cron syntax for scheduling repository archive cleanup, e.g. `@every 1h`.
910909

911910
#### Cron - Delete all old actions from database ('cron.delete_old_actions')
912911
- `ENABLED`: **false**: Enable service.
913912
- `RUN_AT_START`: **false**: Run tasks at start up time (if ENABLED).
914-
- `NO_SUCCESS_NOTICE`: **false**: Set to true to switch off success notices.
913+
- `NOTICE_ON_SUCCESS`: **false**: Set to true to switch on success notices.
915914
- `SCHEDULE`: **@every 168h**: Cron syntax to set how often to check.
916915
- `OLDER_THAN`: **@every 8760h**: any action older than this expression will be deleted from database, suggest using `8760h` (1 year) because that's the max length of heatmap.
917916

services/cron/setting.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ type BaseConfig struct {
2626
Enabled bool
2727
RunAtStart bool
2828
Schedule string
29-
NoSuccessNotice bool
29+
NoticeOnSuccess bool
3030
}
3131

3232
// OlderThanConfig represents a cron task with OlderThan setting
@@ -66,7 +66,7 @@ func (b *BaseConfig) DoRunAtStart() bool {
6666

6767
// DoNoticeOnSuccess returns whether a success notice should be posted
6868
func (b *BaseConfig) DoNoticeOnSuccess() bool {
69-
return !b.NoSuccessNotice
69+
return b.NoticeOnSuccess
7070
}
7171

7272
// FormatMessage returns a message for the task

services/cron/tasks_basic.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,9 @@ func registerUpdateMirrorTask() {
2828

2929
RegisterTaskFatal("update_mirrors", &UpdateMirrorTaskConfig{
3030
BaseConfig: BaseConfig{
31-
Enabled: true,
32-
RunAtStart: false,
33-
Schedule: "@every 10m",
34-
NoSuccessNotice: true,
31+
Enabled: true,
32+
RunAtStart: false,
33+
Schedule: "@every 10m",
3534
},
3635
PullLimit: 50,
3736
PushLimit: 50,

0 commit comments

Comments
 (0)