From abdcd60dac8dff40dd365f23a15d84747f22bfa3 Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Fri, 7 Feb 2014 04:09:46 -0700 Subject: [PATCH] hooked up websockets to stream output --- pkg/build/build.go | 3 ++- pkg/handler/commits.go | 2 +- pkg/queue/queue.go | 12 ++++++------ pkg/template/pages/repo_commit.html | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/pkg/build/build.go b/pkg/build/build.go index 3fb5aecd9..b086d4f47 100644 --- a/pkg/build/build.go +++ b/pkg/build/build.go @@ -354,7 +354,7 @@ func (b *Builder) run() error { b.BuildState.Finished = time.Now().UTC().Unix() // get the exit code if possible - b.BuildState.ExitCode = wait.StatusCode //b.container.State.ExitCode + b.BuildState.ExitCode = wait.StatusCode return nil } @@ -404,6 +404,7 @@ func (b *Builder) writeDockerfile(dir string) error { dockerfile.WriteEnv("GOPATH", "/var/cache/drone") dockerfile.WriteAdd("id_rsa", "/root/.ssh/id_rsa") dockerfile.WriteRun("chmod 600 /root/.ssh/id_rsa") + dockerfile.WriteRun("echo 'StrictHostKeyChecking no' > /root/.ssh/config") } dockerfile.WriteAdd("proxy.sh", "/etc/drone.d/") diff --git a/pkg/handler/commits.go b/pkg/handler/commits.go index 8ad1b0a12..5ac30cf11 100644 --- a/pkg/handler/commits.go +++ b/pkg/handler/commits.go @@ -48,7 +48,7 @@ func CommitShow(w http.ResponseWriter, r *http.Request, u *User, repo *Repo) err // generate a token to connect with the websocket // handler and stream output, if the build is running. - data.Token = channel.Token(fmt.Sprintf( + data.Token = channel.CreateStream(fmt.Sprintf( "%s/commit/%s/builds/%s", repo.Slug, commit.Hash, builds[0].Slug)) // render the repository template. diff --git a/pkg/queue/queue.go b/pkg/queue/queue.go index 0f0fb7b7a..643df98de 100644 --- a/pkg/queue/queue.go +++ b/pkg/queue/queue.go @@ -106,9 +106,9 @@ func (b *BuildTask) execute() error { // make sure a channel exists for the repository, // the commit, and the commit output (TODO) - reposlug := fmt.Sprintf("%s/%s/%s", b.Repo.Host, b.Repo.Owner, b.Repo.Slug) - commitslug := fmt.Sprintf("%s/%s/%s/commit/%s", b.Repo.Host, b.Repo.Owner, b.Repo.Slug, b.Commit.Hash) - consoleslug := fmt.Sprintf("%s/%s/%s/commit/%s/builds/%s", b.Repo.Host, b.Repo.Owner, b.Repo.Slug, b.Commit.Hash, b.Build.Slug) + reposlug := fmt.Sprintf("%s/%s/%s", b.Repo.Host, b.Repo.Owner, b.Repo.Name) + commitslug := fmt.Sprintf("%s/%s/%s/commit/%s", b.Repo.Host, b.Repo.Owner, b.Repo.Name, b.Commit.Hash) + consoleslug := fmt.Sprintf("%s/%s/%s/commit/%s/builds/%s", b.Repo.Host, b.Repo.Owner, b.Repo.Name, b.Commit.Hash, b.Build.Slug) channel.Create(reposlug) channel.Create(commitslug) channel.CreateStream(consoleslug) @@ -223,7 +223,7 @@ func updateGitHubStatus(repo *Repo, commit *Commit) error { } client := github.New(user.GithubToken) - return client.Repos.CreateStatus(repo.Owner, repo.Slug, status, settings.URL().String(), message, commit.Hash) + return client.Repos.CreateStatus(repo.Owner, repo.Name, status, settings.URL().String(), message, commit.Hash) } func (t *BuildTask) sendEmail(c *notification.Context) error { @@ -250,7 +250,7 @@ func (t *BuildTask) sendFailureEmail(c *notification.Context) error { // loop through and email recipients for _, email := range t.Script.Notifications.Email.Recipients { - if err := mail.SendFailure(t.Repo.Slug, email, c); err != nil { + if err := mail.SendFailure(t.Repo.Name, email, c); err != nil { return err } } @@ -263,7 +263,7 @@ func (t *BuildTask) sendSuccessEmail(c *notification.Context) error { // loop through and email recipients for _, email := range t.Script.Notifications.Email.Recipients { - if err := mail.SendSuccess(t.Repo.Slug, email, c); err != nil { + if err := mail.SendSuccess(t.Repo.Name, email, c); err != nil { return err } } diff --git a/pkg/template/pages/repo_commit.html b/pkg/template/pages/repo_commit.html index 93553a0d8..acadcdec3 100644 --- a/pkg/template/pages/repo_commit.html +++ b/pkg/template/pages/repo_commit.html @@ -64,7 +64,7 @@ outputWS.onclose = function (e) { window.location.reload(); }; outputWS.onmessage = function (e) { outputBox.innerHTML += formatLine(e.data); - window.scrollTo(0, document.body.scrollHeight) + //window.scrollTo(0, document.body.scrollHeight) }; var re = /\u001B\[([0-9]+;?)*[Km]/g; var styles = new Array();