Пример #1
0
// message returns a formatted message to send through a notification system.
// event specifies what happened - tests completed e.x.
// kind specifies the notification system.
func message(job *database.Job, service, event, kind string) string {
	logs := database.GetCommandLogsForJob(job.ID)

	ctx := map[string]interface{}{
		"TasksFinished":  job.TasksFinished,
		"DeployFinished": job.DeployFinished,
		"Repository":     job.Repository,
		"Branch":         job.Branch,
		"Commit":         job.Commit,
		"CommitURL":      job.CommitURL,
		"Name":           job.Name,
		"Email":          job.Email,
		"CommandLogs":    logs,
		"URL":            job.URL(),
	}

	tmpl, err := getTemplate(service, event, kind)

	if err != nil {
		log.Println(err)
		return ""
	}

	var buf bytes.Buffer
	tmpl.Execute(&buf, ctx)
	return buf.String()
}
Пример #2
0
// NewMessage converts a job and event type to a message that can be send
// through a websocket.
func NewMessage(job *database.Job, event string) *Message {
	return &Message{
		Name:           job.Name,
		Email:          job.Email,
		Event:          event,
		RepositoryName: job.Repository.Name,
		Branch:         job.Branch,
		Status:         job.Status(),
		URL:            job.URL(),
	}
}
Пример #3
0
// newStatus returns a status struct with the correct URL and messages.
func newStatus(job *database.Job) *commitStatus {
	state := statusSuccess

	if !job.Passed() {
		state = statusFailed
	}

	return &commitStatus{
		State:       statusMessages[state]["state"],
		TargetURL:   job.URL(),
		Description: statusMessages[state]["description"],
		Context:     "continuous-integration/leeeroyci",
	}
}