From 543a46a755cf759ddaefceaf31ec91dd86515236 Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Thu, 30 Apr 2015 00:42:23 -0700 Subject: [PATCH] contacts agent to cancel build --- server/builds.go | 19 +++++++++++++++++++ server/static/scripts/views/build.html | 4 ++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/server/builds.go b/server/builds.go index 265c36d4d..6c6213dbf 100644 --- a/server/builds.go +++ b/server/builds.go @@ -1,7 +1,10 @@ package server import ( + "fmt" "io" + "net/http" + "net/url" "strconv" "time" @@ -239,5 +242,21 @@ func KillBuild(c *gin.Context) { return } + // get the agent from the repository so we can + // notify the agent to kill the build. + agent, err := store.BuildAgent(repo.FullName, build.Number) + if err != nil { + c.JSON(200, build) + return + } + url_, _ := url.Parse("http://" + agent.Addr) + url_.Path = fmt.Sprintf("/cancel/%s/%v", repo.FullName, build.Number) + resp, err := http.Post(url_.String(), "application/json", nil) + if err != nil { + c.Fail(500, err) + return + } + defer resp.Body.Close() + c.JSON(200, build) } diff --git a/server/static/scripts/views/build.html b/server/static/scripts/views/build.html index 0d141216f..1e634a623 100644 --- a/server/static/scripts/views/build.html +++ b/server/static/scripts/views/build.html @@ -3,8 +3,8 @@ Back
- - + +