Skip to content

Commit 305493c

Browse files
committed
create wrapper function for cd success
1 parent c375839 commit 305493c

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

ci-runner/executor/stage/cdStages.go

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,8 @@ func (impl *CdStage) handleCDEvent(ciCdRequest *helper.CiCdTriggerEvent) (bool,
102102
// specifically for isolated environment type, for IsVirtualExecution we don't send success event.
103103
// but failure event is sent in case of error.
104104
if err == nil && !ciCdRequest.CommonWorkflowRequest.IsVirtualExecution {
105-
log.Println(util.DEVTRON, " event")
106-
event := adaptor.NewCdCompleteEvent(ciCdRequest.CommonWorkflowRequest, true).
107-
WithPluginArtifacts(allPluginArtifacts).
108-
WithIsArtifactUploaded(artifactUploaded)
109-
err = helper.SendCDEvent(ciCdRequest.CommonWorkflowRequest, event)
110-
if err != nil {
111-
log.Println(err)
112-
}
113-
log.Println(util.DEVTRON, " /event")
105+
//send cd success event
106+
sendCDSuccessEvent(ciCdRequest.CommonWorkflowRequest, allPluginArtifacts, artifactUploaded)
114107
}
115108
return artifactUploaded, err
116109
}
@@ -248,3 +241,15 @@ func sendCDFailureEvent(ciRequest *helper.CommonWorkflowRequest, err *helper.CdS
248241
log.Println(e)
249242
}
250243
}
244+
245+
func sendCDSuccessEvent(commonWorkflowRequest *helper.CommonWorkflowRequest, allPluginArtifacts *helper.PluginArtifacts, artifactUploaded bool) {
246+
log.Println(util.DEVTRON, " event")
247+
event := adaptor.NewCdCompleteEvent(commonWorkflowRequest, true).
248+
WithPluginArtifacts(allPluginArtifacts).
249+
WithIsArtifactUploaded(artifactUploaded)
250+
err := helper.SendCDEvent(commonWorkflowRequest, event)
251+
if err != nil {
252+
log.Println(err)
253+
}
254+
log.Println(util.DEVTRON, " /event")
255+
}

0 commit comments

Comments
 (0)