Example #1
0
func cloneSource(task *service.RestTask, project *model.ProjectRef, config *model.Project, cloneDir string) error {
	// Fetch the outermost repo for the task
	err := clone(
		cloneOptions{
			repo:     fmt.Sprintf("[email protected]:%v/%v.git", project.Owner, project.Repo),
			revision: task.Revision,
			rootDir:  cloneDir,
			depth:    defaultCloneDepth,
		},
		false,
	)

	if err != nil {
		return err
	}

	// Then fetch each of the modules
	variant := config.FindBuildVariant(task.BuildVariant)
	if variant == nil {
		return fmt.Errorf("couldn't find build variant '%v' in config", task.BuildVariant)
	}
	for _, moduleName := range variant.Modules {
		module, err := config.GetModuleByName(moduleName)
		if err != nil || module == nil {
			return fmt.Errorf("variant refers to a module '%v' that doesn't exist.", moduleName)
		}
		moduleBase := filepath.Join(cloneDir, module.Prefix, module.Name)
		fmt.Printf("Fetching module %v at %v\n", moduleName, module.Branch)
		err = clone(cloneOptions{
			repo:     module.Repo,
			revision: module.Branch,
			rootDir:  filepath.ToSlash(moduleBase),
		}, false)
		if err != nil {
			return err
		}
	}
	return nil
}
Example #2
0
// Makes sure that the dependencies for the tasks have the correct fields,
// and that the fields reference valid tasks.
func verifyTaskRequirements(project *model.Project) []ValidationError {
	errs := []ValidationError{}
	for _, bvt := range project.FindAllBuildVariantTasks() {
		for _, r := range bvt.Requires {
			if project.FindProjectTask(r.Name) == nil {
				if r.Name == model.AllDependencies {
					errs = append(errs, ValidationError{Message: fmt.Sprintf(
						"task '%v': * is not supported for requirement selectors", bvt.Name)})
				} else {
					errs = append(errs,
						ValidationError{Message: fmt.Sprintf(
							"task '%v' requires non-existent task '%v'", bvt.Name, r.Name)})
				}
			}
			if r.Variant != "" && r.Variant != model.AllVariants && project.FindBuildVariant(r.Variant) == nil {
				errs = append(errs, ValidationError{Message: fmt.Sprintf(
					"task '%v' requires non-existent variant '%v'", bvt.Name, r.Variant)})
			}
		}
	}
	return errs
}