diff --git a/ciStages.go b/ciStages.go index cfab3827..47aa7a3a 100644 --- a/ciStages.go +++ b/ciStages.go @@ -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 { @@ -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) @@ -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) @@ -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) diff --git a/helper/EventHelper.go b/helper/EventHelper.go index aafa6d81..f6316817 100644 --- a/helper/EventHelper.go +++ b/helper/EventHelper.go @@ -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 { diff --git a/util/CommonConstants.go b/util/CommonConstants.go index 39a96450..103ae126 100644 --- a/util/CommonConstants.go +++ b/util/CommonConstants.go @@ -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"