| 112 | } |
| 113 | |
| 114 | func makePipelinePlanV200( |
| 115 | subtaskMetas []plugin.SubTaskMeta, |
| 116 | connection *models.GitlabConnection, |
| 117 | scopeDetails []*srvhelper.ScopeDetail[models.GitlabProject, models.GitlabScopeConfig], |
| 118 | ) (coreModels.PipelinePlan, errors.Error) { |
| 119 | plans := make(coreModels.PipelinePlan, 0, 3*len(scopeDetails)) |
| 120 | for _, scope := range scopeDetails { |
| 121 | gitlabProject, scopeConfig := scope.Scope, scope.ScopeConfig |
| 122 | var stage coreModels.PipelineStage |
| 123 | // construct subtasks |
| 124 | task, err := helper.MakePipelinePlanTask(pluginName, subtaskMetas, scopeConfig.Entities, map[string]interface{}{ |
| 125 | "connectionId": connection.ID, |
| 126 | "projectId": gitlabProject.GitlabId, |
| 127 | "fullName": gitlabProject.PathWithNamespace, |
| 128 | }) |
| 129 | if err != nil { |
| 130 | return nil, err |
| 131 | } |
| 132 | stage = append(stage, task) |
| 133 | |
| 134 | // collect git data by gitextractor if CODE was requested |
| 135 | if utils.StringsContains(scopeConfig.Entities, plugin.DOMAIN_TYPE_CODE) || len(scopeConfig.Entities) == 0 { |
| 136 | cloneUrl, err := errors.Convert01(url.Parse(gitlabProject.HttpUrlToRepo)) |
| 137 | if err != nil { |
| 138 | return nil, err |
| 139 | } |
| 140 | cloneUrl.User = url.UserPassword("git", connection.Token) |
| 141 | gitextOpts := map[string]interface{}{ |
| 142 | "url": cloneUrl.String(), |
| 143 | "name": gitlabProject.Name, |
| 144 | "fullName": gitlabProject.PathWithNamespace, |
| 145 | "repoId": didgen.NewDomainIdGenerator(&models.GitlabProject{}).Generate(connection.ID, gitlabProject.GitlabId), |
| 146 | "proxy": connection.Proxy, |
| 147 | "connectionId": gitlabProject.ConnectionId, |
| 148 | "pluginName": "gitlab", |
| 149 | } |
| 150 | if len(scopeConfig.PrSizeExcludedFileExtensions) > 0 { |
| 151 | // pass excluded file extensions to gitextractor to support PR Size exclusion |
| 152 | gitextOpts["excludeFileExtensions"] = scopeConfig.PrSizeExcludedFileExtensions |
| 153 | } |
| 154 | stage = append(stage, &coreModels.PipelineTask{ |
| 155 | Plugin: "gitextractor", |
| 156 | Options: gitextOpts, |
| 157 | }) |
| 158 | } |
| 159 | |
| 160 | plans = append(plans, stage) |
| 161 | |
| 162 | // refdiff part |
| 163 | if scopeConfig.Refdiff != nil { |
| 164 | task := &coreModels.PipelineTask{ |
| 165 | Plugin: "refdiff", |
| 166 | Options: scopeConfig.Refdiff, |
| 167 | } |
| 168 | plans = append(plans, coreModels.PipelineStage{task}) |
| 169 | } |
| 170 | } |
| 171 | return plans, nil |