Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: poll container image output in post ci step #17

Merged
merged 1 commit into from
Oct 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading