@@ -73,8 +73,6 @@ func RunJobs(jobs []orchestrator.Job, prService ci.PullRequestService, orgServic
73
73
slog .Debug ("Variable info" , "TG_PROVIDER_CACHE_DIR" , os .Getenv ("TG_PROVIDER_CACHE_DIR" ))
74
74
slog .Debug ("Variable info" , "TERRAGRUNT_PROVIDER_CACHE_DIR" , os .Getenv ("TERRAGRUNT_PROVIDER_CACHE_DIR" ))
75
75
76
- runStartedAt := time .Now ()
77
-
78
76
exectorResults := make ([]execution.DiggerExecutorResult , len (jobs ))
79
77
appliesPerProject := make (map [string ]bool )
80
78
@@ -98,13 +96,9 @@ func RunJobs(jobs []orchestrator.Job, prService ci.PullRequestService, orgServic
98
96
continue
99
97
}
100
98
101
- executorResult , output , err := run (command , job , policyChecker , orgService , SCMOrganisation , SCMrepository , job .PullRequestNumber , job .RequestedBy , reporter , lock , prService , job .Namespace , workingDir , planStorage , appliesPerProject )
99
+ executorResult , _ , err := run (command , job , policyChecker , orgService , SCMOrganisation , SCMrepository , job .PullRequestNumber , job .RequestedBy , reporter , lock , prService , job .Namespace , workingDir , planStorage , appliesPerProject )
102
100
if err != nil {
103
101
slog .Error ("error while running command for project" , "command" , command , "projectname" , job .ProjectName , "error" , err )
104
- reportErr := backendApi .ReportProjectRun (SCMOrganisation + "-" + SCMrepository , job .ProjectName , runStartedAt , time .Now (), "FAILED" , command , output )
105
- if reportErr != nil {
106
- slog .Error ("error reporting project Run err." , "error" , reportErr )
107
- }
108
102
appliesPerProject [job .ProjectName ] = false
109
103
if executorResult != nil {
110
104
exectorResults [i ] = * executorResult
@@ -114,10 +108,6 @@ func RunJobs(jobs []orchestrator.Job, prService ci.PullRequestService, orgServic
114
108
}
115
109
exectorResults [i ] = * executorResult
116
110
117
- err = backendApi .ReportProjectRun (SCMOrganisation + "-" + SCMrepository , job .ProjectName , runStartedAt , time .Now (), "SUCCESS" , command , output )
118
- if err != nil {
119
- slog .Error ("Error reporting project Run" , "error" , err )
120
- }
121
111
}
122
112
}
123
113
@@ -573,7 +563,6 @@ func RunJob(
573
563
driftNotification * core_drift.Notification ,
574
564
workingDir string ,
575
565
) error {
576
- runStartedAt := time .Now ()
577
566
SCMOrganisation , SCMrepository := utils .ParseRepoNamespace (repo )
578
567
slog .Info ("Running commands for project" , "commands" , job .Commands , "project name" , job .ProjectName )
579
568
@@ -591,10 +580,6 @@ func RunJob(
591
580
slog .Error ("Error publishing comment." , "error" , err )
592
581
}
593
582
slog .Error (msg )
594
- err = backendApi .ReportProjectRun (repo , job .ProjectName , runStartedAt , time .Now (), "FORBIDDEN" , command , msg )
595
- if err != nil {
596
- slog .Error ("Error reporting Run." , "error" , err )
597
- }
598
583
return errors .New (msg )
599
584
}
600
585
@@ -652,61 +637,37 @@ func RunJob(
652
637
if err != nil {
653
638
slog .Error ("Failed to send usage report." , "error" , err )
654
639
}
655
- _ , _ , _ , plan , planJsonOutput , err := diggerExecutor .Plan ()
640
+ _ , _ , _ , _ , planJsonOutput , err := diggerExecutor .Plan ()
656
641
if err != nil {
657
642
msg := fmt .Sprintf ("Failed to Run digger plan command. %v" , err )
658
643
slog .Error (msg )
659
- err = backendApi .ReportProjectRun (repo , job .ProjectName , runStartedAt , time .Now (), "FAILED" , command , msg )
660
- if err != nil {
661
- slog .Error ("Error reporting Run." , "error" , err )
662
- }
663
644
return fmt .Errorf ("%s" , msg )
664
645
}
665
646
planIsAllowed , messages , err := policyChecker .CheckPlanPolicy (SCMrepository , SCMOrganisation , job .ProjectName , job .ProjectDir , planJsonOutput )
666
647
slog .Info (strings .Join (messages , "\n " ))
667
648
if err != nil {
668
649
msg := fmt .Sprintf ("Failed to validate plan %v" , err )
669
650
slog .Error (msg )
670
- err = backendApi .ReportProjectRun (repo , job .ProjectName , runStartedAt , time .Now (), "FAILED" , command , msg )
671
- if err != nil {
672
- slog .Error ("Error reporting Run." , "error" , err )
673
- }
674
651
return fmt .Errorf ("%s" , msg )
675
652
}
676
653
if ! planIsAllowed {
677
654
msg := fmt .Sprintf ("Plan is not allowed" )
678
655
slog .Error (msg )
679
- err = backendApi .ReportProjectRun (repo , job .ProjectName , runStartedAt , time .Now (), "FAILED" , command , msg )
680
- if err != nil {
681
- slog .Error ("Error reporting Run." , "error" , err )
682
- }
683
656
return fmt .Errorf ("%s" , msg )
684
657
} else {
685
- err = backendApi .ReportProjectRun (repo , job .ProjectName , runStartedAt , time .Now (), "SUCCESS" , command , plan )
686
- if err != nil {
687
- slog .Error ("Error reporting Run." , "error" , err )
688
- }
689
658
}
690
659
691
660
case "digger apply" :
692
661
err := usage .SendUsageRecord (requestedBy , job .EventName , "apply" )
693
662
if err != nil {
694
663
slog .Error ("Failed to send usage report." , "error" , err )
695
664
}
696
- _ , _ , output , err : = diggerExecutor .Apply ()
665
+ _ , _ , _ , err = diggerExecutor .Apply ()
697
666
if err != nil {
698
667
msg := fmt .Sprintf ("Failed to Run digger apply command. %v" , err )
699
668
slog .Error (msg )
700
- err = backendApi .ReportProjectRun (repo , job .ProjectName , runStartedAt , time .Now (), "FAILED" , command , msg )
701
- if err != nil {
702
- slog .Error ("Error reporting Run." , "error" , err )
703
- }
704
669
return fmt .Errorf ("%s" , msg )
705
670
}
706
- err = backendApi .ReportProjectRun (repo , job .ProjectName , runStartedAt , time .Now (), "SUCCESS" , command , output )
707
- if err != nil {
708
- slog .Error ("Error reporting Run." , "error" , err )
709
- }
710
671
case "digger destroy" :
711
672
err := usage .SendUsageRecord (requestedBy , job .EventName , "destroy" )
712
673
if err != nil {
@@ -719,14 +680,10 @@ func RunJob(
719
680
}
720
681
721
682
case "digger drift-detect" :
722
- output , err : = runDriftDetection (policyChecker , SCMOrganisation , SCMrepository , job .ProjectName , requestedBy , job .EventName , diggerExecutor , driftNotification )
683
+ _ , err = runDriftDetection (policyChecker , SCMOrganisation , SCMrepository , job .ProjectName , requestedBy , job .EventName , diggerExecutor , driftNotification )
723
684
if err != nil {
724
685
return fmt .Errorf ("failed to Run digger drift-detect command. %v" , err )
725
686
}
726
- err = backendApi .ReportProjectRun (repo , job .ProjectName , runStartedAt , time .Now (), "SUCCESS" , command , output )
727
- if err != nil {
728
- slog .Error ("Error reporting Run." , "error" , err )
729
- }
730
687
}
731
688
732
689
}
0 commit comments