@@ -680,6 +680,9 @@ func (handler CoreAppRestHandlerImpl) buildCiPipelineResp(appId int, ciPipeline
680680 DockerBuildArgs : ciPipeline .DockerArgs ,
681681 VulnerabilityScanEnabled : ciPipeline .ScanEnabled ,
682682 IsExternal : ciPipeline .IsExternal ,
683+ ParentCiPipeline : ciPipeline .ParentCiPipeline ,
684+ ParentAppId : ciPipeline .ParentAppId ,
685+ LinkedCount : ciPipeline .LinkedCount ,
683686 }
684687
685688 //build ciPipelineMaterial resp
@@ -691,9 +694,10 @@ func (handler CoreAppRestHandlerImpl) buildCiPipelineResp(appId int, ciPipeline
691694 return nil , err
692695 }
693696 ciPipelineMaterialConfig := & appBean.CiPipelineMaterialConfig {
694- Type : ciMaterial .Source .Type ,
695- Value : ciMaterial .Source .Value ,
696- CheckoutPath : gitMaterial .CheckoutPath ,
697+ Type : ciMaterial .Source .Type ,
698+ Value : ciMaterial .Source .Value ,
699+ CheckoutPath : gitMaterial .CheckoutPath ,
700+ GitMaterialId : gitMaterial .Id ,
697701 }
698702 ciPipelineMaterialsConfig = append (ciPipelineMaterialsConfig , ciPipelineMaterialConfig )
699703 }
@@ -1534,7 +1538,7 @@ func (handler CoreAppRestHandlerImpl) createWorkflowInDb(workflowName string, ap
15341538func (handler CoreAppRestHandlerImpl ) createCiPipeline (appId int , userId int32 , workflowId int , ciPipelineData * appBean.CiPipelineDetails ) (int , error ) {
15351539
15361540 // if ci pipeline is of external type, then throw error as we are not supporting it as of now
1537- if ciPipelineData .IsExternal {
1541+ if ciPipelineData .ParentCiPipeline == 0 && ciPipelineData . ParentAppId == 0 && ciPipelineData . IsExternal {
15381542 err := errors .New ("external ci pipeline creation is not supported yet" )
15391543 handler .logger .Error ("external ci pipeline creation is not supported yet" )
15401544 return 0 , err
@@ -1543,8 +1547,15 @@ func (handler CoreAppRestHandlerImpl) createCiPipeline(appId int, userId int32,
15431547 // build ci pipeline materials starts
15441548 var ciMaterialsRequest []* bean.CiMaterial
15451549 for _ , ciMaterial := range ciPipelineData .CiPipelineMaterialsConfig {
1546- //finding gitMaterial by appId and checkoutPath
1547- gitMaterial , err := handler .materialRepository .FindByAppIdAndCheckoutPath (appId , ciMaterial .CheckoutPath )
1550+ var gitMaterial * pipelineConfig.GitMaterial
1551+ var err error
1552+ if ciPipelineData .ParentCiPipeline == 0 && ciPipelineData .ParentAppId == 0 {
1553+ //finding gitMaterial by appId and checkoutPath
1554+ gitMaterial , err = handler .materialRepository .FindByAppIdAndCheckoutPath (appId , ciMaterial .CheckoutPath )
1555+ } else {
1556+ //if linkedci find git material by it's id
1557+ gitMaterial , err = handler .materialRepository .FindById (ciMaterial .GitMaterialId )
1558+ }
15481559 if err != nil {
15491560 handler .logger .Errorw ("service err, FindByAppIdAndCheckoutPath in CreateWorkflows" , "err" , err , "appId" , appId )
15501561 return 0 , err
@@ -1587,6 +1598,9 @@ func (handler CoreAppRestHandlerImpl) createCiPipeline(appId int, userId int32,
15871598 CiMaterial : ciMaterialsRequest ,
15881599 PreBuildStage : ciPipelineData .PreBuildStage ,
15891600 PostBuildStage : ciPipelineData .PostBuildStage ,
1601+ ParentCiPipeline : ciPipelineData .ParentCiPipeline ,
1602+ ParentAppId : ciPipelineData .ParentAppId ,
1603+ LinkedCount : ciPipelineData .LinkedCount ,
15901604 },
15911605 }
15921606
0 commit comments