コード例 #1
0
ファイル: template.go プロジェクト: francoishill/leeroyci
// 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
ファイル: message.go プロジェクト: francoishill/leeroyci
// 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
ファイル: hipchat.go プロジェクト: francoishill/leeroyci
// Convert a job to a hipchat payload.
func payloadHipchat(job *database.Job, event, channel string) hipchatPayload {
	msg := message(job, database.NotificationServiceHipchat, event, TypeText)

	return hipchatPayload{
		Color:   "green",
		Notify:  true,
		Format:  "text",
		Room:    channel,
		From:    "LeeroyCI",
		Message: msg,
		Status:  job.Passed(),
	}
}
コード例 #4
0
ファイル: request.go プロジェクト: francoishill/leeroyci
// 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",
	}
}
コード例 #5
0
ファイル: email.go プロジェクト: francoishill/leeroyci
// emailSubject returns the subject for an email.
func emailSubject(job *database.Job, event string) string {
	if event == EventBuild {
		return fmt.Sprintf("%s/%s build", job.Repository.Name, job.Branch)
	}

	if event == EventTest {
		return fmt.Sprintf("%s/%s tests", job.Repository.Name, job.Branch)
	}

	if event == EventDeployStart {
		return fmt.Sprintf("%s/%s deployment started", job.Repository.Name, job.Branch)
	}

	if event == EventDeployEnd {
		return fmt.Sprintf("%s/%s deploy %s", job.Repository.Name, job.Branch, job.Status())
	}

	return "LeeroyCI is confused - not sure which message this is."
}
コード例 #6
0
ファイル: runner.go プロジェクト: francoishill/leeroyci
// deploy is a wrapper around the run commnad to make running the deploy commands
// in a separate go routine more convenient.
func deploy(job *database.Job, repository *database.Repository) {
	notification.Notify(job, notification.EventDeployStart)
	run(job, repository, database.CommandKindDeploy)
	job.DeployDone()
	notification.Notify(job, notification.EventDeployEnd)
}