Skip to content

Commit

Permalink
poll image output in post ci
Browse files Browse the repository at this point in the history
  • Loading branch information
Shivam-nagar23 committed Oct 17, 2024
1 parent a960335 commit d214de1
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions ci-runner/executor/stage/ciStages.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ func (impl *CiStage) runCIStages(ciContext cicxt.CiContext, ciCdRequest *helper.
metrics.PostCiStartTime = start
var pluginArtifacts *helper.PluginArtifacts
if len(ciCdRequest.CommonWorkflowRequest.PostCiSteps) > 0 {
pluginArtifacts, err = impl.runPostCiSteps(ciCdRequest, scriptEnvs, refStageMap, preCiStageOutVariable, metrics, artifactUploaded, dest, digest)
pluginArtifacts, resultsFromPlugin, err = impl.runPostCiSteps(ciCdRequest, scriptEnvs, refStageMap, preCiStageOutVariable, metrics, artifactUploaded, dest, digest)
postCiDuration = time.Since(start).Seconds()
if err != nil {
return artifactUploaded, err
Expand Down Expand Up @@ -436,7 +436,7 @@ func (impl *CiStage) extractDigest(ciCdRequest *helper.CiCdTriggerEvent, dest st
return digest, err
}

func (impl *CiStage) runPostCiSteps(ciCdRequest *helper.CiCdTriggerEvent, scriptEnvs map[string]string, refStageMap map[int][]*helper.StepObject, preCiStageOutVariable map[int]map[string]*helper.VariableObject, metrics *helper.CIMetrics, artifactUploaded bool, dest string, digest string) (*helper.PluginArtifacts, error) {
func (impl *CiStage) runPostCiSteps(ciCdRequest *helper.CiCdTriggerEvent, scriptEnvs map[string]string, refStageMap map[int][]*helper.StepObject, preCiStageOutVariable map[int]map[string]*helper.VariableObject, metrics *helper.CIMetrics, artifactUploaded bool, dest string, digest string) (*helper.PluginArtifacts, json.RawMessage, error) {
log.Println("running POST-CI steps")
// sending build success as true always as post-ci triggers only if ci gets success
scriptEnvs[util.ENV_VARIABLE_BUILD_SUCCESS] = "true"
Expand All @@ -446,13 +446,20 @@ func (impl *CiStage) runPostCiSteps(ciCdRequest *helper.CiCdTriggerEvent, script
pluginArtifactsFromFile, _, step, err := impl.stageExecutorManager.RunCiCdSteps(helper.STEP_TYPE_POST, ciCdRequest.CommonWorkflowRequest, ciCdRequest.CommonWorkflowRequest.PostCiSteps, refStageMap, scriptEnvs, preCiStageOutVariable)
if err != nil {
log.Println("error in running Post Ci Steps", "err", err)
return nil, helper.NewCiStageError(err).
return nil, nil, helper.NewCiStageError(err).
WithMetrics(metrics).
WithFailureMessage(fmt.Sprintf(workFlow.PostCiFailed.String(), step.Name)).
WithArtifactUploaded(artifactUploaded)
}
//sent by orchestrator if copy container image v2 is configured
return pluginArtifactsFromFile, nil

// considering pull images from Container repo Plugin in post ci steps also.
// making it non-blocking if results are not available (in case of err)
resultsFromPlugin, fileErr := extractOutResultsIfExists()
if fileErr != nil {
log.Println("error in getting results", "err", fileErr.Error())
}
return pluginArtifactsFromFile, resultsFromPlugin, nil
}

func runImageScanning(dest string, digest string, ciCdRequest *helper.CiCdTriggerEvent, metrics *helper.CIMetrics, artifactUploaded bool) error {
Expand Down

0 comments on commit d214de1

Please sign in to comment.