@@ -104,7 +104,7 @@ type TriggerService interface {
104
104
TriggerPostStage (request bean.TriggerRequest ) (* bean4.ManifestPushTemplate , error )
105
105
TriggerPreStage (request bean.TriggerRequest ) (* bean4.ManifestPushTemplate , error )
106
106
107
- TriggerAutoCDOnPreStageSuccess (triggerContext bean.TriggerContext , cdPipelineId , ciArtifactId , workflowId int , triggerdBy int32 ) error
107
+ TriggerAutoCDOnPreStageSuccess (triggerContext bean.TriggerContext , cdPipelineId , ciArtifactId , workflowId int ) error
108
108
109
109
TriggerStageForBulk (triggerRequest bean.TriggerRequest ) error
110
110
@@ -646,7 +646,7 @@ func (impl *TriggerServiceImpl) TriggerAutomaticDeployment(request bean.TriggerR
646
646
WorkflowType : bean3 .CD_WORKFLOW_TYPE_DEPLOY ,
647
647
ExecutorType : cdWorkflow .WORKFLOW_EXECUTOR_TYPE_SYSTEM ,
648
648
Status : cdWorkflow .WorkflowInitiated , // deployment Initiated for auto trigger
649
- TriggeredBy : 1 ,
649
+ TriggeredBy : triggeredBy ,
650
650
StartedOn : triggeredAt ,
651
651
Namespace : impl .config .GetDefaultNamespace (),
652
652
CdWorkflowId : cdWf .Id ,
@@ -677,13 +677,12 @@ func (impl *TriggerServiceImpl) TriggerAutomaticDeployment(request bean.TriggerR
677
677
impl .logger .Errorw ("error in fetching environment deployment config by appId and envId" , "appId" , pipeline .AppId , "envId" , pipeline .EnvironmentId , "err" , err )
678
678
return err
679
679
}
680
- // setting triggeredBy as 1(system user) since case of auto trigger
681
- validationErr := impl .validateDeploymentTriggerRequest (ctx , adapter .NewValidateDeploymentTriggerObj (runner , pipeline , artifact .ImageDigest , envDeploymentConfig , 1 , false ))
680
+ validationErr := impl .validateDeploymentTriggerRequest (ctx , adapter .NewValidateDeploymentTriggerObj (runner , pipeline , artifact .ImageDigest , envDeploymentConfig , triggeredBy , false ))
682
681
if validationErr != nil {
683
682
impl .logger .Errorw ("validation error deployment request" , "cdWfr" , runner .Id , "err" , validationErr )
684
683
return validationErr
685
684
}
686
- releaseErr := impl .TriggerCD (ctx , artifact , cdWf .Id , savedWfr .Id , pipeline , envDeploymentConfig , triggeredAt )
685
+ releaseErr := impl .TriggerCD (ctx , artifact , cdWf .Id , savedWfr .Id , pipeline , envDeploymentConfig , triggeredAt , triggeredBy )
687
686
// if releaseErr found, then the mark current deployment Failed and return
688
687
if releaseErr != nil {
689
688
err := impl .cdWorkflowCommonService .MarkCurrentDeploymentFailed (runner , releaseErr , triggeredBy )
@@ -695,38 +694,38 @@ func (impl *TriggerServiceImpl) TriggerAutomaticDeployment(request bean.TriggerR
695
694
return nil
696
695
}
697
696
698
- func (impl * TriggerServiceImpl ) TriggerCD (ctx context.Context , artifact * repository3.CiArtifact , cdWorkflowId , wfrId int , pipeline * pipelineConfig.Pipeline , envDeploymentConfig * bean9.DeploymentConfig , triggeredAt time.Time ) error {
697
+ func (impl * TriggerServiceImpl ) TriggerCD (ctx context.Context , artifact * repository3.CiArtifact , cdWorkflowId , wfrId int , pipeline * pipelineConfig.Pipeline , envDeploymentConfig * bean9.DeploymentConfig , triggeredAt time.Time , triggeredBy int32 ) error {
699
698
impl .logger .Debugw ("automatic pipeline trigger attempt async" , "artifactId" , artifact .Id )
700
- err := impl .triggerReleaseAsync (ctx , artifact , cdWorkflowId , wfrId , pipeline , envDeploymentConfig , triggeredAt )
699
+ err := impl .triggerReleaseAsync (ctx , artifact , cdWorkflowId , wfrId , pipeline , envDeploymentConfig , triggeredAt , triggeredBy )
701
700
if err != nil {
702
701
impl .logger .Errorw ("error in cd trigger" , "err" , err )
703
702
return err
704
703
}
705
704
return err
706
705
}
707
706
708
- func (impl * TriggerServiceImpl ) triggerReleaseAsync (ctx context.Context , artifact * repository3.CiArtifact , cdWorkflowId , wfrId int , pipeline * pipelineConfig.Pipeline , envDeploymentConfig * bean9.DeploymentConfig , triggeredAt time.Time ) error {
709
- err := impl .validateAndTrigger (ctx , pipeline , envDeploymentConfig , artifact , cdWorkflowId , wfrId , triggeredAt )
707
+ func (impl * TriggerServiceImpl ) triggerReleaseAsync (ctx context.Context , artifact * repository3.CiArtifact , cdWorkflowId , wfrId int , pipeline * pipelineConfig.Pipeline , envDeploymentConfig * bean9.DeploymentConfig , triggeredAt time.Time , triggeredBy int32 ) error {
708
+ err := impl .validateAndTrigger (ctx , pipeline , envDeploymentConfig , artifact , cdWorkflowId , wfrId , triggeredAt , triggeredBy )
710
709
if err != nil {
711
710
impl .logger .Errorw ("error in trigger for pipeline" , "pipelineId" , strconv .Itoa (pipeline .Id ))
712
711
}
713
712
impl .logger .Debugw ("trigger attempted for all pipeline " , "artifactId" , artifact .Id )
714
713
return err
715
714
}
716
715
717
- func (impl * TriggerServiceImpl ) validateAndTrigger (ctx context.Context , p * pipelineConfig.Pipeline , envDeploymentConfig * bean9.DeploymentConfig , artifact * repository3.CiArtifact , cdWorkflowId , wfrId int , triggeredAt time.Time ) error {
716
+ func (impl * TriggerServiceImpl ) validateAndTrigger (ctx context.Context , p * pipelineConfig.Pipeline , envDeploymentConfig * bean9.DeploymentConfig , artifact * repository3.CiArtifact , cdWorkflowId , wfrId int , triggeredAt time.Time , triggeredBy int32 ) error {
718
717
//TODO: verify this logic
719
718
object := impl .enforcerUtil .GetAppRBACNameByAppId (p .AppId )
720
719
envApp := strings .Split (object , "/" )
721
720
if len (envApp ) != 2 {
722
721
impl .logger .Error ("invalid req, app and env not found from rbac" )
723
722
return errors .New ("invalid req, app and env not found from rbac" )
724
723
}
725
- err := impl .releasePipeline (ctx , p , envDeploymentConfig , artifact , cdWorkflowId , wfrId , triggeredAt )
724
+ err := impl .releasePipeline (ctx , p , envDeploymentConfig , artifact , cdWorkflowId , wfrId , triggeredAt , triggeredBy )
726
725
return err
727
726
}
728
727
729
- func (impl * TriggerServiceImpl ) releasePipeline (ctx context.Context , pipeline * pipelineConfig.Pipeline , envDeploymentConfig * bean9.DeploymentConfig , artifact * repository3.CiArtifact , cdWorkflowId , wfrId int , triggeredAt time.Time ) error {
728
+ func (impl * TriggerServiceImpl ) releasePipeline (ctx context.Context , pipeline * pipelineConfig.Pipeline , envDeploymentConfig * bean9.DeploymentConfig , artifact * repository3.CiArtifact , cdWorkflowId , wfrId int , triggeredAt time.Time , triggeredBy int32 ) error {
730
729
startTime := time .Now ()
731
730
defer func () {
732
731
impl .logger .Debugw ("auto trigger release process completed" , "timeTaken" , time .Since (startTime ), "cdPipelineId" , pipeline .Id , "artifactId" , artifact .Id , "wfrId" , wfrId )
@@ -751,8 +750,7 @@ func (impl *TriggerServiceImpl) releasePipeline(ctx context.Context, pipeline *p
751
750
752
751
adapter .SetPipelineFieldsInOverrideRequest (request , pipeline , envDeploymentConfig )
753
752
754
- // setting deployedBy as 1(system user) since case of auto trigger
755
- id , _ , err := impl .handleCDTriggerRelease (ctx , request , envDeploymentConfig , triggeredAt , 1 )
753
+ id , _ , err := impl .handleCDTriggerRelease (ctx , request , envDeploymentConfig , triggeredAt , triggeredBy )
756
754
if err != nil {
757
755
impl .logger .Errorw ("error in auto cd pipeline trigger" , "pipelineId" , pipeline .Id , "artifactId" , artifact .Id , "err" , err )
758
756
} else {
0 commit comments