MCPcopy Create free account
hub / github.com/apache/devlake / createPipelineByBlueprint

Function createPipelineByBlueprint

backend/server/services/blueprint.go:312–356  ·  view source on GitHub ↗
(blueprint *models.Blueprint, syncPolicy *models.SyncPolicy)

Source from the content-addressed store, hash-verified

310}
311
312func createPipelineByBlueprint(blueprint *models.Blueprint, syncPolicy *models.SyncPolicy) (*models.Pipeline, errors.Error) {
313 var plan models.PipelinePlan
314 var err errors.Error
315 if blueprint.Mode == models.BLUEPRINT_MODE_NORMAL {
316 plan, err = MakePlanForBlueprint(blueprint, syncPolicy)
317 if err != nil {
318 blueprintLog.Error(err, fmt.Sprintf("failed to MakePlanForBlueprint on blueprint:[%d][%s]", blueprint.ID, blueprint.Name))
319 return nil, err
320 }
321 } else {
322 plan = blueprint.Plan
323 }
324
325 newPipeline := models.NewPipeline{}
326 newPipeline.Plan = plan
327 newPipeline.Name = blueprint.Name
328 newPipeline.BlueprintId = blueprint.ID
329 newPipeline.Labels = blueprint.Labels
330 newPipeline.Priority = blueprint.Priority
331 newPipeline.SyncPolicy = blueprint.SyncPolicy
332
333 // if the plan is empty, we should not create the pipeline
334 // var shouldCreatePipeline bool
335 // for _, stage := range plan {
336 // for _, task := range stage {
337 // switch task.Plugin {
338 // case "org", "refdiff", "dora":
339 // default:
340 // if !plan.IsEmpty() {
341 // shouldCreatePipeline = true
342 // }
343 // }
344 // }
345 // }
346 // if !shouldCreatePipeline {
347 // return nil, ErrEmptyPlan
348 // }
349 pipeline, err := CreatePipeline(&newPipeline, false)
350 // Return all created tasks to the User
351 if err != nil {
352 blueprintLog.Error(err, fmt.Sprintf("%s on blueprint:[%d][%s]", failToCreateCronJob, blueprint.ID, blueprint.Name))
353 return nil, errors.Convert(err)
354 }
355 return pipeline, nil
356}
357
358// MakePlanForBlueprint generates pipeline plan by version
359func MakePlanForBlueprint(blueprint *models.Blueprint, syncPolicy *models.SyncPolicy) (models.PipelinePlan, errors.Error) {

Callers 2

RunMethod · 0.85
TriggerBlueprintFunction · 0.85

Calls 4

MakePlanForBlueprintFunction · 0.85
CreatePipelineFunction · 0.85
ErrorMethod · 0.65
ConvertMethod · 0.45

Tested by

no test coverage detected