diff --git a/server/builds.go b/server/builds.go index 265c36d4..6c6213db 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 0d141216..1e634a62 100644 --- a/server/static/scripts/views/build.html +++ b/server/static/scripts/views/build.html @@ -3,8 +3,8 @@ Back
- - + +