Skip to content

Commit b465a9e

Browse files
Merge branch 'develop' into force-abort-fix
2 parents 507ea4f + 92b080b commit b465a9e

File tree

11 files changed

+232
-195
lines changed

11 files changed

+232
-195
lines changed

api/restHandler/app/pipeline/trigger/PipelineTriggerRestHandler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,14 @@ func (handler PipelineTriggerRestHandlerImpl) OverrideConfig(w http.ResponseWrit
144144
triggerContext := bean3.TriggerContext{
145145
Context: ctx,
146146
}
147-
mergeResp, err := handler.cdTriggerService.ManualCdTrigger(triggerContext, &overrideRequest)
147+
mergeResp, helmPackageName, err := handler.cdTriggerService.ManualCdTrigger(triggerContext, &overrideRequest)
148148
span.End()
149149
if err != nil {
150150
handler.logger.Errorw("request err, OverrideConfig", "err", err, "payload", overrideRequest)
151151
common.WriteJsonResp(w, err, err.Error(), http.StatusInternalServerError)
152152
return
153153
}
154-
res := map[string]interface{}{"releaseId": mergeResp}
154+
res := map[string]interface{}{"releaseId": mergeResp, "helmPackageName": helmPackageName}
155155
common.WriteJsonResp(w, err, res, http.StatusOK)
156156
}
157157

internal/sql/repository/helper/AppListingRepositoryQueryBuilder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ func (impl AppListingRepositoryQueryBuilder) buildAppListingWhereCondition(appLi
260260
}
261261
if isNotDeployedFilterApplied {
262262
deploymentAppType := "manifest_download"
263-
whereCondition += " and (p.deployment_app_created=? and (p.deployment_app_type != ? or dc.deployment_app_type != ? ) or a.id NOT IN (SELECT app_id from pipeline) "
263+
whereCondition += " and (p.deployment_app_created=? and (p.deployment_app_type <> ? or dc.deployment_app_type <> ? ) or a.id NOT IN (SELECT app_id from pipeline) "
264264
queryParams = append(queryParams, false, deploymentAppType, deploymentAppType)
265265
if len(appStatusExcludingNotDeployed) > 0 {
266266
whereCondition += " or aps.status IN (?) "

pkg/deployment/deployedApp/DeployedAppService.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func (impl *DeployedAppServiceImpl) StopStartApp(ctx context.Context, stopReques
110110
Context: ctx,
111111
ReferenceId: stopRequest.ReferenceId,
112112
}
113-
id, err := impl.cdTriggerService.ManualCdTrigger(triggerContext, overrideRequest)
113+
id, _, err := impl.cdTriggerService.ManualCdTrigger(triggerContext, overrideRequest)
114114
if err != nil {
115115
impl.logger.Errorw("error in stopping app", "err", err, "appId", stopRequest.AppId, "envId", stopRequest.EnvironmentId)
116116
return 0, err

pkg/deployment/gitOps/git/GitOperationService.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ type GitOperationService interface {
5656
CloneInDir(repoUrl, chartDir string) (string, error)
5757
ReloadGitOpsProvider() error
5858
UpdateGitHostUrlByProvider(request *apiBean.GitOpsConfigDto) error
59+
GetRepoUrlWithUserName(url string) (string, error)
5960
}
6061

6162
type GitOperationServiceImpl struct {
@@ -475,3 +476,7 @@ func (impl *GitOperationServiceImpl) addConfigFileToChart(config *ChartConfig, d
475476
}
476477
return nil
477478
}
479+
480+
func (impl *GitOperationServiceImpl) GetRepoUrlWithUserName(url string) (string, error) {
481+
return url, nil
482+
}

pkg/deployment/trigger/devtronApps/PreStageTriggerService.go

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,57 @@ func (impl *TriggerServiceImpl) TriggerPreStage(request bean.TriggerRequest) err
146146
return nil
147147
}
148148

149+
func (impl *TriggerServiceImpl) TriggerAutoCDOnPreStageSuccess(triggerContext bean.TriggerContext, cdPipelineId, ciArtifactId, workflowId int, triggerdBy int32, scanExecutionHistoryId int) error {
150+
pipeline, err := impl.pipelineRepository.FindById(cdPipelineId)
151+
if err != nil {
152+
return err
153+
}
154+
if pipeline.TriggerType == pipelineConfig.TRIGGER_TYPE_AUTOMATIC {
155+
ciArtifact, err := impl.ciArtifactRepository.Get(ciArtifactId)
156+
if err != nil {
157+
return err
158+
}
159+
cdWorkflow, err := impl.cdWorkflowRepository.FindById(workflowId)
160+
if err != nil {
161+
return err
162+
}
163+
// TODO : confirm about this logic used for applyAuth
164+
165+
// checking if deployment is triggered already, then ignore trigger
166+
deploymentTriggeredAlready := impl.checkDeploymentTriggeredAlready(cdWorkflow.Id)
167+
if deploymentTriggeredAlready {
168+
impl.logger.Warnw("deployment is already triggered, so ignoring this msg", "cdPipelineId", cdPipelineId, "ciArtifactId", ciArtifactId, "workflowId", workflowId)
169+
return nil
170+
}
171+
172+
triggerRequest := bean.TriggerRequest{
173+
CdWf: cdWorkflow,
174+
Pipeline: pipeline,
175+
Artifact: ciArtifact,
176+
TriggeredBy: triggerdBy,
177+
TriggerContext: triggerContext,
178+
}
179+
180+
triggerRequest.TriggerContext.Context = context.Background()
181+
err = impl.TriggerAutomaticDeployment(triggerRequest)
182+
if err != nil {
183+
return err
184+
}
185+
}
186+
return nil
187+
}
188+
func (impl *TriggerServiceImpl) checkDeploymentTriggeredAlready(wfId int) bool {
189+
deploymentTriggeredAlready := false
190+
// TODO : need to check this logic for status check in case of multiple deployments requirement for same workflow
191+
workflowRunner, err := impl.cdWorkflowRepository.FindByWorkflowIdAndRunnerType(context.Background(), wfId, bean2.CD_WORKFLOW_TYPE_DEPLOY)
192+
if err != nil {
193+
impl.logger.Errorw("error occurred while fetching workflow runner", "wfId", wfId, "err", err)
194+
return deploymentTriggeredAlready
195+
}
196+
deploymentTriggeredAlready = workflowRunner.CdWorkflowId == wfId
197+
return deploymentTriggeredAlready
198+
}
199+
149200
func (impl *TriggerServiceImpl) createStartingWfAndRunner(request bean.TriggerRequest, triggeredAt time.Time) (*pipelineConfig.CdWorkflow, *pipelineConfig.CdWorkflowRunner, error) {
150201
triggeredBy := request.TriggeredBy
151202
artifact := request.Artifact

0 commit comments

Comments
 (0)