@@ -387,7 +387,7 @@ func (c *Config) registerAllJobs() {
387387 j .Provider = provider
388388 j .InitializeRuntimeFields ()
389389 j .Name = name
390- c .mergeNotificationDefaults (& j .SlackConfig , & j .MailConfig )
390+ c .mergeNotificationDefaults (& j .SlackConfig , & j .MailConfig , & j . SaveConfig )
391391 c .injectDedup (& j .SlackConfig , & j .MailConfig )
392392 j .buildMiddlewares (wm )
393393 _ = c .sh .AddJob (j )
@@ -401,15 +401,15 @@ func (c *Config) registerAllJobs() {
401401 j .Provider = provider
402402 j .InitializeRuntimeFields ()
403403 j .Name = name
404- c .mergeNotificationDefaults (& j .SlackConfig , & j .MailConfig )
404+ c .mergeNotificationDefaults (& j .SlackConfig , & j .MailConfig , & j . SaveConfig )
405405 c .injectDedup (& j .SlackConfig , & j .MailConfig )
406406 j .buildMiddlewares (wm )
407407 _ = c .sh .AddJob (j )
408408 }
409409 for name , j := range c .LocalJobs {
410410 _ = defaults .Set (j )
411411 j .Name = name
412- c .mergeNotificationDefaults (& j .SlackConfig , & j .MailConfig )
412+ c .mergeNotificationDefaults (& j .SlackConfig , & j .MailConfig , & j . SaveConfig )
413413 c .injectDedup (& j .SlackConfig , & j .MailConfig )
414414 j .buildMiddlewares (wm )
415415 _ = c .sh .AddJob (j )
@@ -423,15 +423,15 @@ func (c *Config) registerAllJobs() {
423423 j .Provider = provider
424424 j .InitializeRuntimeFields ()
425425 j .Name = name
426- c .mergeNotificationDefaults (& j .SlackConfig , & j .MailConfig )
426+ c .mergeNotificationDefaults (& j .SlackConfig , & j .MailConfig , & j . SaveConfig )
427427 c .injectDedup (& j .SlackConfig , & j .MailConfig )
428428 j .buildMiddlewares (wm )
429429 _ = c .sh .AddJob (j )
430430 }
431431 for name , j := range c .ComposeJobs {
432432 _ = defaults .Set (j )
433433 j .Name = name
434- c .mergeNotificationDefaults (& j .SlackConfig , & j .MailConfig )
434+ c .mergeNotificationDefaults (& j .SlackConfig , & j .MailConfig , & j . SaveConfig )
435435 c .injectDedup (& j .SlackConfig , & j .MailConfig )
436436 j .buildMiddlewares (wm )
437437 _ = c .sh .AddJob (j )
@@ -450,9 +450,10 @@ func (c *Config) injectDedup(slack *middlewares.SlackConfig, mail *middlewares.M
450450// mergeNotificationDefaults copies global notification settings to job-level configs
451451// when the job-level field has its zero value. This allows partial overrides where
452452// a job can specify only `mail-only-on-error: true` while inheriting SMTP settings.
453- func (c * Config ) mergeNotificationDefaults (slack * middlewares.SlackConfig , mail * middlewares.MailConfig ) {
453+ func (c * Config ) mergeNotificationDefaults (slack * middlewares.SlackConfig , mail * middlewares.MailConfig , save * middlewares. SaveConfig ) {
454454 c .mergeSlackDefaults (slack )
455455 c .mergeMailDefaults (mail )
456+ c .mergeSaveDefaults (save )
456457}
457458
458459// mergeSlackDefaults copies global Slack settings to job config where job has zero values
@@ -501,12 +502,27 @@ func (c *Config) mergeMailDefaults(job *middlewares.MailConfig) {
501502 if job .EmailFrom == "" {
502503 job .EmailFrom = global .EmailFrom
503504 }
505+ if job .EmailSubject == "" {
506+ job .EmailSubject = global .EmailSubject
507+ }
504508 // MailOnlyOnError: inherit from global only when the job didn't explicitly set it (nil).
505509 if job .MailOnlyOnError == nil && global .MailOnlyOnError != nil {
506510 job .MailOnlyOnError = middlewares .BoolPtr (* global .MailOnlyOnError )
507511 }
508512}
509513
514+ // mergeSaveDefaults copies global Save settings to job config where job has zero values
515+ func (c * Config ) mergeSaveDefaults (job * middlewares.SaveConfig ) {
516+ global := & c .Global .SaveConfig
517+ if job .SaveFolder == "" {
518+ job .SaveFolder = global .SaveFolder
519+ }
520+ // SaveOnlyOnError: inherit from global only when the job didn't explicitly set it (nil).
521+ if job .SaveOnlyOnError == nil && global .SaveOnlyOnError != nil {
522+ job .SaveOnlyOnError = middlewares .BoolPtr (* global .SaveOnlyOnError )
523+ }
524+ }
525+
510526// UserContainerDefault is the sentinel value that explicitly requests the container's default user,
511527// overriding any global default-user setting.
512528const UserContainerDefault = "default"
@@ -658,7 +674,7 @@ func (c *Config) dockerLabelsUpdate(labels map[string]map[string]string) {
658674 j .Provider = c .dockerHandler .GetDockerProvider ()
659675 j .InitializeRuntimeFields ()
660676 j .Name = name
661- c .mergeNotificationDefaults (& j .SlackConfig , & j .MailConfig )
677+ c .mergeNotificationDefaults (& j .SlackConfig , & j .MailConfig , & j . SaveConfig )
662678 c .injectDedup (& j .SlackConfig , & j .MailConfig )
663679 }
664680 syncJobMap (c , c .ExecJobs , parsedLabelConfig .ExecJobs , execPrep , JobSourceLabel , "exec" )
@@ -672,15 +688,15 @@ func (c *Config) dockerLabelsUpdate(labels map[string]map[string]string) {
672688 j .Provider = c .dockerHandler .GetDockerProvider ()
673689 j .InitializeRuntimeFields ()
674690 j .Name = name
675- c .mergeNotificationDefaults (& j .SlackConfig , & j .MailConfig )
691+ c .mergeNotificationDefaults (& j .SlackConfig , & j .MailConfig , & j . SaveConfig )
676692 c .injectDedup (& j .SlackConfig , & j .MailConfig )
677693 }
678694 syncJobMap (c , c .RunJobs , parsedLabelConfig .RunJobs , runPrep , JobSourceLabel , "run" )
679695
680696 localPrep := func (name string , j * LocalJobConfig ) {
681697 _ = defaults .Set (j )
682698 j .Name = name
683- c .mergeNotificationDefaults (& j .SlackConfig , & j .MailConfig )
699+ c .mergeNotificationDefaults (& j .SlackConfig , & j .MailConfig , & j . SaveConfig )
684700 c .injectDedup (& j .SlackConfig , & j .MailConfig )
685701 }
686702
@@ -693,14 +709,14 @@ func (c *Config) dockerLabelsUpdate(labels map[string]map[string]string) {
693709 j .Provider = c .dockerHandler .GetDockerProvider ()
694710 j .InitializeRuntimeFields ()
695711 j .Name = name
696- c .mergeNotificationDefaults (& j .SlackConfig , & j .MailConfig )
712+ c .mergeNotificationDefaults (& j .SlackConfig , & j .MailConfig , & j . SaveConfig )
697713 c .injectDedup (& j .SlackConfig , & j .MailConfig )
698714 }
699715
700716 composePrep := func (name string , j * ComposeJobConfig ) {
701717 _ = defaults .Set (j )
702718 j .Name = name
703- c .mergeNotificationDefaults (& j .SlackConfig , & j .MailConfig )
719+ c .mergeNotificationDefaults (& j .SlackConfig , & j .MailConfig , & j . SaveConfig )
704720 c .injectDedup (& j .SlackConfig , & j .MailConfig )
705721 }
706722
@@ -785,7 +801,7 @@ func (c *Config) iniConfigUpdate() error {
785801 j .Provider = c .dockerHandler .GetDockerProvider ()
786802 j .InitializeRuntimeFields ()
787803 j .Name = name
788- c .mergeNotificationDefaults (& j .SlackConfig , & j .MailConfig )
804+ c .mergeNotificationDefaults (& j .SlackConfig , & j .MailConfig , & j . SaveConfig )
789805 c .injectDedup (& j .SlackConfig , & j .MailConfig )
790806 }
791807 syncJobMap (c , c .ExecJobs , parsed .ExecJobs , execPrep , JobSourceINI , "exec" )
@@ -799,15 +815,15 @@ func (c *Config) iniConfigUpdate() error {
799815 j .Provider = c .dockerHandler .GetDockerProvider ()
800816 j .InitializeRuntimeFields ()
801817 j .Name = name
802- c .mergeNotificationDefaults (& j .SlackConfig , & j .MailConfig )
818+ c .mergeNotificationDefaults (& j .SlackConfig , & j .MailConfig , & j . SaveConfig )
803819 c .injectDedup (& j .SlackConfig , & j .MailConfig )
804820 }
805821 syncJobMap (c , c .RunJobs , parsed .RunJobs , runPrep , JobSourceINI , "run" )
806822
807823 localPrep := func (name string , j * LocalJobConfig ) {
808824 _ = defaults .Set (j )
809825 j .Name = name
810- c .mergeNotificationDefaults (& j .SlackConfig , & j .MailConfig )
826+ c .mergeNotificationDefaults (& j .SlackConfig , & j .MailConfig , & j . SaveConfig )
811827 c .injectDedup (& j .SlackConfig , & j .MailConfig )
812828 }
813829 syncJobMap (c , c .LocalJobs , parsed .LocalJobs , localPrep , JobSourceINI , "local" )
@@ -821,15 +837,15 @@ func (c *Config) iniConfigUpdate() error {
821837 j .Provider = c .dockerHandler .GetDockerProvider ()
822838 j .InitializeRuntimeFields ()
823839 j .Name = name
824- c .mergeNotificationDefaults (& j .SlackConfig , & j .MailConfig )
840+ c .mergeNotificationDefaults (& j .SlackConfig , & j .MailConfig , & j . SaveConfig )
825841 c .injectDedup (& j .SlackConfig , & j .MailConfig )
826842 }
827843 syncJobMap (c , c .ServiceJobs , parsed .ServiceJobs , svcPrep , JobSourceINI , "service" )
828844
829845 composePrep := func (name string , j * ComposeJobConfig ) {
830846 _ = defaults .Set (j )
831847 j .Name = name
832- c .mergeNotificationDefaults (& j .SlackConfig , & j .MailConfig )
848+ c .mergeNotificationDefaults (& j .SlackConfig , & j .MailConfig , & j . SaveConfig )
833849 c .injectDedup (& j .SlackConfig , & j .MailConfig )
834850 }
835851 syncJobMap (c , c .ComposeJobs , parsed .ComposeJobs , composePrep , JobSourceINI , "compose" )
0 commit comments