github.com/unclejack/drone@v0.2.1-0.20140918182345-831b034aa33b/pkg/handler/builds.go (about) 1 package handler 2 3 import ( 4 "net/http" 5 6 "github.com/drone/drone/pkg/database" 7 . "github.com/drone/drone/pkg/model" 8 ) 9 10 type BuildResult struct { 11 Status string 12 } 13 14 // Returns the combined stdout / stderr for an individual Build. 15 func BuildOut(w http.ResponseWriter, r *http.Request, u *User, repo *Repo) error { 16 branch := r.FormValue("branch") 17 if branch == "" { 18 branch = "master" 19 } 20 21 hash := r.FormValue(":commit") 22 labl := r.FormValue(":label") 23 24 // get the commit from the database 25 commit, err := database.GetCommitBranchHash(branch, hash, repo.ID) 26 if err != nil { 27 return err 28 } 29 30 // get the build from the database 31 build, err := database.GetBuildSlug(labl, commit.ID) 32 if err != nil { 33 return err 34 } 35 36 return RenderText(w, build.Stdout, http.StatusOK) 37 } 38 39 // Returns the combined stdout / stderr for an individual Build. 40 func BuildStatus(w http.ResponseWriter, r *http.Request, repo *Repo) error { 41 branch := r.FormValue("branch") 42 if branch == "" { 43 branch = "master" 44 } 45 46 hash := r.FormValue(":commit") 47 labl := r.FormValue(":label") 48 49 // get the commit from the database 50 commit, err := database.GetCommitBranchHash(branch, hash, repo.ID) 51 if err != nil { 52 return err 53 } 54 55 // get the build from the database 56 build, err := database.GetBuildSlug(labl, commit.ID) 57 if err != nil { 58 return err 59 } 60 61 build_result := BuildResult{build.Status} 62 63 return RenderJson(w, build_result) 64 } 65 66 // Returns the gzipped stdout / stderr for an individual Build 67 func BuildOutGzip(w http.ResponseWriter, r *http.Request, u *User) error { 68 // TODO 69 return nil 70 }