diff --git a/Makefile b/Makefile index aac0782b0..d4fa3cc69 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ deps: go get -u github.com/elazarl/go-bindata-assetfs/... go get -u github.com/dchest/jsmin go get -u github.com/franela/goblin - go get -u github.com/go-swagger/go-swagger + go get -u github.com/go-swagger/go-swagger/... go get -u github.com/PuerkitoBio/goquery go get -u github.com/russross/blackfriday diff --git a/controller/index.go b/controller/index.go index d70a41319..b93ebe071 100644 --- a/controller/index.go +++ b/controller/index.go @@ -5,6 +5,7 @@ import ( "strconv" "time" + log "github.com/Sirupsen/logrus" "github.com/gin-gonic/gin" "github.com/drone/drone/model" @@ -22,7 +23,10 @@ func ShowIndex(c *gin.Context) { return } - repos, _ := model.GetRepoList(db, user) + repos, err := model.GetRepoList(db, user) + if err != nil { + log.Errorf(err) + } c.HTML(200, "repos.html", gin.H{ "User": user, diff --git a/drone.go b/drone.go index a30e8df60..ba0c753f1 100644 --- a/drone.go +++ b/drone.go @@ -37,7 +37,7 @@ func main() { remote_ := remote.Load(env) // setup the runner - engine_ := engine.Load(database_, remote_) + engine_ := engine.Load(database_, env, remote_) // setup the server and start the listener server_ := server.Load(env) diff --git a/engine/engine.go b/engine/engine.go index 58d3821fd..63b85e3d0 100644 --- a/engine/engine.go +++ b/engine/engine.go @@ -17,6 +17,7 @@ import ( "github.com/drone/drone/model" "github.com/drone/drone/remote" "github.com/drone/drone/shared/docker" + "github.com/drone/drone/shared/envconfig" "github.com/samalba/dockerclient" ) @@ -54,18 +55,31 @@ type engine struct { bus *eventbus updater *updater pool *pool + envs []string } // Load creates a new build engine, loaded with registered nodes from the // database. The registered nodes are added to the pool of nodes to immediately // start accepting workloads. -func Load(db *sql.DB, remote remote.Remote) Engine { +func Load(db *sql.DB, env envconfig.Env, remote remote.Remote) Engine { engine := &engine{} engine.bus = newEventbus() engine.pool = newPool() engine.db = db engine.updater = &updater{engine.bus, db, remote} + // quick fix to propogate HTTP_PROXY variables + // throughout the build environment. + if env := env.Get("HTTP_PROXY"); len(env) != 0 { + engine.envs = append(engine.envs, "HTTP_PROXY="+env) + } + if env := env.Get("HTTPS_PROXY"); len(env) != 0 { + engine.envs = append(engine.envs, "HTTPS_PROXY="+env) + } + if env := env.Get("NO_PROXY"); len(env) != 0 { + engine.envs = append(engine.envs, "NO_PROXY="+env) + } + nodes, err := model.GetNodeList(db) if err != nil { log.Fatalf("failed to get nodes from database. %s", err) @@ -174,7 +188,7 @@ func (e *engine) Schedule(req *Task) { // run all bulid jobs for _, job := range req.Jobs { req.Job = job - runJob(req, e.updater, client) + e.runJob(req, e.updater, client) } // update overall status based on each job @@ -192,7 +206,7 @@ func (e *engine) Schedule(req *Task) { } // run notifications - err = runJobNotify(req, client) + err = e.runJobNotify(req, client) if err != nil { log.Errorf("error executing notification step. %s", err) } @@ -235,7 +249,7 @@ func newDockerClient(addr, cert, key, ca string) (dockerclient.Client, error) { return dockerclient.NewDockerClient(addr, tlc) } -func runJob(r *Task, updater *updater, client dockerclient.Client) error { +func (e *engine) runJob(r *Task, updater *updater, client dockerclient.Client) error { name := fmt.Sprintf("drone_build_%d_job_%d", r.Build.ID, r.Job.ID) @@ -281,6 +295,7 @@ func runJob(r *Task, updater *updater, client dockerclient.Client) error { Image: DefaultAgent, Entrypoint: DefaultEntrypoint, Cmd: args, + Env: e.envs, HostConfig: dockerclient.HostConfig{ Binds: []string{"/var/run/docker.sock:/var/run/docker.sock"}, }, @@ -358,7 +373,7 @@ func runJob(r *Task, updater *updater, client dockerclient.Client) error { return nil } -func runJobNotify(r *Task, client dockerclient.Client) error { +func (e *engine) runJobNotify(r *Task, client dockerclient.Client) error { name := fmt.Sprintf("drone_build_%d_notify", r.Build.ID) @@ -383,6 +398,7 @@ func runJobNotify(r *Task, client dockerclient.Client) error { Image: DefaultAgent, Entrypoint: DefaultEntrypoint, Cmd: args, + Env: e.envs, HostConfig: dockerclient.HostConfig{ Binds: []string{"/var/run/docker.sock:/var/run/docker.sock"}, },