Merge pull request #571 from bradrydzewski/master

updated yaml
This commit is contained in:
Brad Rydzewski 2014-10-14 22:50:05 -07:00
commit 2f232b8c98
3 changed files with 19 additions and 11 deletions

View file

@ -17,12 +17,15 @@ services:
- postgres - postgres
- mysql - mysql
notify: notify:
email:
recipients:
- brad@drone.io
gitter: gitter:
room_id: 76f5e5ec935c5b40259a room_id: $$GITTER_ROOM
token: $$GITTER_KEY token: $$GITTER_KEY
on_started: false on_started: false
on_success: false on_success: true
on_failure: false on_failure: true
publish: publish:
s3: s3:
@ -34,3 +37,5 @@ publish:
source: packaging/output/ source: packaging/output/
target: $DRONE_BRANCH/ target: $DRONE_BRANCH/
recursive: true recursive: true
when:
owner: drone

View file

@ -24,11 +24,11 @@ type Gitter struct {
func (g *Gitter) Send(context *model.Request) error { func (g *Gitter) Send(context *model.Request) error {
switch { switch {
case context.Commit.Status == "Started" && g.Started: case context.Commit.Status == model.StatusStarted && g.Started:
return g.sendStarted(context) return g.sendStarted(context)
case context.Commit.Status == "Success" && g.Success: case context.Commit.Status == model.StatusSuccess && g.Success:
return g.sendSuccess(context) return g.sendSuccess(context)
case context.Commit.Status == "Failure" && g.Failure: case context.Commit.Status == model.StatusFailure && g.Failure:
return g.sendFailure(context) return g.sendFailure(context)
} }
@ -70,9 +70,8 @@ func (g *Gitter) send(msg string) error {
// create headers // create headers
headers := make(map[string]string) headers := make(map[string]string)
headers["Accept"] = "application/json"
headers["Authorization"] = fmt.Sprintf("Bearer %s", g.Token) headers["Authorization"] = fmt.Sprintf("Bearer %s", g.Token)
go sendJson(url, payload, headers) return sendJson(url, payload, headers)
return nil
} }

View file

@ -105,11 +105,14 @@ func getBuildUrl(context *model.Request) string {
// helper fuction to sent HTTP Post requests // helper fuction to sent HTTP Post requests
// with JSON data as the payload. // with JSON data as the payload.
func sendJson(url string, payload []byte, headers map[string]string) { func sendJson(url string, payload []byte, headers map[string]string) error {
client := &http.Client{} client := &http.Client{}
buf := bytes.NewBuffer(payload) buf := bytes.NewBuffer(payload)
req, err := http.NewRequest("POST", url, buf) req, err := http.NewRequest("POST", url, buf)
if err != nil {
return err
}
req.Header.Set("Content-Type", "application/json") req.Header.Set("Content-Type", "application/json")
if headers != nil { if headers != nil {
@ -120,7 +123,8 @@ func sendJson(url string, payload []byte, headers map[string]string) {
resp, err := client.Do(req) resp, err := client.Do(req)
if err != nil { if err != nil {
return return err
} }
resp.Body.Close() resp.Body.Close()
return nil
} }