Beispiel #1
0
// RefreshTasksCache updates a build document so that the tasks cache reflects the correct current
// state of the tasks it represents.
func RefreshTasksCache(buildId string) error {
	tasks, err := FindAllTasks(
		bson.M{TaskBuildIdKey: buildId},
		bson.M{
			TaskIdKey:          1,
			TaskDisplayNameKey: 1,
			TaskStatusKey:      1,
			TaskDetailsKey:     1,
			TaskStartTimeKey:   1,
			TaskTimeTakenKey:   1,
			TaskActivatedKey:   1,
			TaskDependsOnKey:   1,
		},
		db.NoSort,
		db.NoSkip,
		db.NoLimit,
	)
	if err != nil {
		return err
	}

	cache := CreateTasksCache(tasks)

	return build.SetTasksCache(buildId, cache)
}
Beispiel #2
0
// RefreshTasksCache updates a build document so that the tasks cache reflects the correct current
// state of the tasks it represents.
func RefreshTasksCache(buildId string) error {
	tasks, err := FindAllTasks(
		bson.M{TaskBuildIdKey: buildId},
		bson.M{
			TaskIdKey:          1,
			TaskDisplayNameKey: 1,
			TaskStatusKey:      1,
			TaskDetailsKey:     1,
			TaskStartTimeKey:   1,
			TaskTimeTakenKey:   1,
			TaskActivatedKey:   1,
		},
		db.NoSort,
		db.NoSkip,
		db.NoLimit,
	)
	if err != nil {
		return err
	}

	cache := make([]build.TaskCache, 0, len(tasks))
	for _, t := range tasks {
		cache = append(cache, cacheFromTask(&t))
	}
	return build.SetTasksCache(buildId, cache)
}
Beispiel #3
0
// RefreshTasksCache updates a build document so that the tasks cache reflects the correct current
// state of the tasks it represents.
func RefreshTasksCache(buildId string) error {
	tasks, err := task.Find(task.ByBuildId(buildId).WithFields(task.IdKey, task.DisplayNameKey, task.StatusKey,
		task.DetailsKey, task.StartTimeKey, task.TimeTakenKey, task.ActivatedKey, task.DependsOnKey))
	if err != nil {
		return err
	}
	cache := CreateTasksCache(tasks)
	return build.SetTasksCache(buildId, cache)
}
Beispiel #4
0
//AddTasksToBuild creates the tasks for the given build of a project
func AddTasksToBuild(b *build.Build, project *Project, v *version.Version,
	taskNames []string) (*build.Build, error) {

	// find the build variant for this project/build
	buildVariant := project.FindBuildVariant(b.BuildVariant)
	if buildVariant == nil {
		return nil, fmt.Errorf("Could not find build %v in %v project file",
			b.BuildVariant, project.Identifier)
	}

	// create the new tasks for the build
	tasks, err := createTasksForBuild(
		project, buildVariant, b, v, BuildTaskIdTable(project, v), taskNames)
	if err != nil {
		return nil, fmt.Errorf("error creating tasks for build %v: %v",
			b.Id, err)
	}

	// insert the tasks into the db
	for _, task := range tasks {
		evergreen.Logger.Logf(slogger.INFO, "Creating task “%v”", task.DisplayName)
		if err := task.Insert(); err != nil {
			return nil, fmt.Errorf("error inserting task %v: %v", task.Id, err)
		}
	}

	// create task caches for all of the tasks, and add them into the build
	for _, t := range tasks {
		b.Tasks = append(b.Tasks, cacheFromTask(t))
	}

	// update the build to hold the new tasks
	if err = build.SetTasksCache(b.Id, b.Tasks); err != nil {
		return nil, err
	}

	return b, nil
}