Skip to content
Open
Show file tree
Hide file tree
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
29 changes: 15 additions & 14 deletions ciStages.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,17 @@ func runCIStages(ciCdRequest *helper.CiCdTriggerEvent) (artifactUploaded bool, e
}
// git handling
log.Println(util.DEVTRON, " git")
err = helper.CloneAndCheckout(ciCdRequest.CiRequest.CiProjectDetails)
if err != nil {
log.Println(util.DEVTRON, "clone err: ", err)
return artifactUploaded, err
}
log.Println(util.DEVTRON, " /git")

// Start docker daemon
log.Println(util.DEVTRON, " docker-build")
if ciCdRequest.CiRequest.Type != util.WEBHOOK {
err = helper.CloneAndCheckout(ciCdRequest.CiRequest.CiProjectDetails)
if err != nil {
log.Println(util.DEVTRON, "clone err: ", err)
return artifactUploaded, err
}
log.Println(util.DEVTRON, " /git")

// Start docker daemon
log.Println(util.DEVTRON, " docker-build")
}
helper.StartDockerDaemon(ciCdRequest.CiRequest.DockerConnection, ciCdRequest.CiRequest.DockerRegistryURL, ciCdRequest.CiRequest.DockerCert, ciCdRequest.CiRequest.DefaultAddressPoolBaseCidr, ciCdRequest.CiRequest.DefaultAddressPoolSize, ciCdRequest.CiRequest.CiBuildDockerMtuValue)
scriptEnvs, err := getGlobalEnvVariables(ciCdRequest)
if err != nil {
Expand All @@ -133,18 +134,18 @@ func runCIStages(ciCdRequest *helper.CiCdTriggerEvent) (artifactUploaded bool, e
refStageMap[ref.Id] = ref.Steps
}

var preeCiStageOutVariable map[int]map[string]*helper.VariableObject
var preCiStageOutVariable map[int]map[string]*helper.VariableObject
var step *helper.StepObject
var preCiDuration float64
start = time.Now()
metrics.PreCiStartTime = start
buildSkipEnabled := ciBuildConfigBean != nil && ciBuildConfigBean.CiBuildType == helper.BUILD_SKIP_BUILD_TYPE
buildSkipEnabled := (ciBuildConfigBean != nil && ciBuildConfigBean.CiBuildType == helper.BUILD_SKIP_BUILD_TYPE) || ciCdRequest.CiRequest.Type == util.WEBHOOK
if len(ciCdRequest.CiRequest.PreCiSteps) > 0 {
if !buildSkipEnabled {
util.LogStage("running PRE-CI steps")
}
// run pre artifact processing
preeCiStageOutVariable, step, err = RunCiCdSteps(STEP_TYPE_PRE, ciCdRequest.CiRequest.PreCiSteps, refStageMap, scriptEnvs, nil)
preCiStageOutVariable, step, err = RunCiCdSteps(STEP_TYPE_PRE, ciCdRequest.CiRequest.PreCiSteps, refStageMap, scriptEnvs, nil)
preCiDuration = time.Since(start).Seconds()
if err != nil {
log.Println(err)
Expand All @@ -169,7 +170,7 @@ func runCIStages(ciCdRequest *helper.CiCdTriggerEvent) (artifactUploaded bool, e
// build success will always be false
scriptEnvs[util.ENV_VARIABLE_BUILD_SUCCESS] = "false"
// run post artifact processing
RunCiCdSteps(STEP_TYPE_POST, postCiStepsToTriggerOnCiFail, refStageMap, scriptEnvs, preeCiStageOutVariable)
RunCiCdSteps(STEP_TYPE_POST, postCiStepsToTriggerOnCiFail, refStageMap, scriptEnvs, preCiStageOutVariable)
}
// code-block ends
return sendFailureNotification(string(Build), ciCdRequest.CiRequest, "", "", metrics, artifactUploaded, err)
Expand All @@ -184,7 +185,7 @@ func runCIStages(ciCdRequest *helper.CiCdTriggerEvent) (artifactUploaded bool, e
// sending build success as true always as post-ci triggers only if ci gets success
scriptEnvs[util.ENV_VARIABLE_BUILD_SUCCESS] = "true"
// run post artifact processing
_, step, err = RunCiCdSteps(STEP_TYPE_POST, ciCdRequest.CiRequest.PostCiSteps, refStageMap, scriptEnvs, preeCiStageOutVariable)
_, step, err = RunCiCdSteps(STEP_TYPE_POST, ciCdRequest.CiRequest.PostCiSteps, refStageMap, scriptEnvs, preCiStageOutVariable)
postCiDuration = time.Since(start).Seconds()
if err != nil {
return sendFailureNotification(string(PostCi)+step.Name, ciCdRequest.CiRequest, "", "", metrics, artifactUploaded, err)
Expand Down
2 changes: 2 additions & 0 deletions helper/EventHelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ type CiRequest struct {
OrchestratorToken string `json:"orchestratorToken"`
ImageRetryCount int `json:"imageRetryCount"`
ImageRetryInterval int `json:"imageRetryInterval"`
Image string `json:"image"`
Type string `json:"type"`
}

type CdRequest struct {
Expand Down
1 change: 1 addition & 0 deletions util/CommonConstants.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const LOCAL_BUILDX_CACHE_LOCATION = LOCAL_BUILDX_LOCATION + "/cache"

const CIEVENT = "CI"
const CDSTAGE = "CD"
const WEBHOOK = "WEBHOOK"
const DRY_RUN = "DryRun"
const ENV_VARIABLE_BUILD_SUCCESS = "BUILD_SUCCESS"

Expand Down