예제 #1
0
func (tp *taskPlugin) Stopped(result engines.ResultSet) (bool, error) {
	nonFatalErrs := []engines.MalformedPayloadError{}

	for _, artifact := range tp.artifacts {
		// If expires is set to this time it's the default value
		if artifact.Expires.IsZero() {
			artifact.Expires = time.Time(tp.context.TaskInfo.Expires)
		}
		switch artifact.Type {
		case "directory":
			err := result.ExtractFolder(artifact.Path, tp.createUploadHandler(artifact.Name, artifact.Expires))
			if err != nil {
				if tp.errorHandled(artifact.Name, artifact.Expires, err) {
					nonFatalErrs = append(nonFatalErrs, engines.NewMalformedPayloadError(err.Error()))
					continue
				}
				return false, err
			}
		case "file":
			fileReader, err := result.ExtractFile(artifact.Path)
			if err != nil {
				if tp.errorHandled(artifact.Name, artifact.Expires, err) {
					nonFatalErrs = append(nonFatalErrs, engines.NewMalformedPayloadError(err.Error()))
					continue
				}
				return false, err
			}
			err = tp.attemptUpload(fileReader, artifact.Path, artifact.Name, artifact.Expires)
			if err != nil {
				return false, err
			}
		}
	}

	if len(nonFatalErrs) > 0 {
		return false, engines.MergeMalformedPayload(nonFatalErrs...)
	}
	return true, nil
}
예제 #2
0
func (taskPlugin) Stopped(result engines.ResultSet) (bool, error) {
	return result.Success(), nil
}