Example #1
0
func sendHipchat(job *database.Job, event string) {
	not, _ := database.GetNotificationForRepoAndType(
		&job.Repository,
		database.NotificationServiceHipchat,
	)

	channel, err := not.GetConfigValue("channel")

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

	payload := payloadHipchat(job, event, channel)

	key, err := not.GetConfigValue("key")

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

	endpoint := endpointHipChat(key)

	_, err = http.Post(
		endpoint,
		"application/x-www-form-urlencoded",
		bytes.NewReader(payload.toURLEncoded()),
	)

	if err != nil {
		log.Println(err)
	}
}
Example #2
0
// Send a notification to Slack
func sendSlack(job *database.Job, event string) {
	notification, _ := database.GetNotificationForRepoAndType(
		&job.Repository,
		database.NotificationServiceSlack,
	)

	channel, err := notification.GetConfigValue("channel")

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

	endpoint, err := notification.GetConfigValue("endpoint")

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

	payload, err := payloadSlack(job, event, channel)

	_, err = http.Post(
		endpoint,
		"application/json",
		bytes.NewReader(payload),
	)

	if err != nil {
		log.Println(err)
	}
}
Example #3
0
// sendCampfire sends a notification to Campfire
func sendCampfire(job *database.Job, event string) {
	payload, err := payloadCampfire(job, event)

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

	not, _ := database.GetNotificationForRepoAndType(
		&job.Repository,
		database.NotificationServiceCampfire,
	)

	id, err := not.GetConfigValue("id")

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

	room, err := not.GetConfigValue("room")

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

	endpoint := endpointCampfire(id, room)

	key, err := not.GetConfigValue("key")

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

	request := requestCampfire(endpoint, key, payload)
	client := &http.Client{}

	_, err = client.Do(request)

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