diff --git a/brigade-worker/prestart.js b/brigade-worker/prestart.js index 169fc2d0d..4ae69d442 100644 --- a/brigade-worker/prestart.js +++ b/brigade-worker/prestart.js @@ -1,6 +1,7 @@ const process = require("process") const fs = require("fs") +// Worker should always set both env vars. The defaults are for local testing. const script = process.env.BRIGADE_SCRIPT || "/etc/brigade/script" const vcsScript = process.env.BRIGADE_VCS_SCRIPT || "/vcs/brigade.js" diff --git a/charts/brigade-project/values.yaml b/charts/brigade-project/values.yaml index 52a46384e..80a461c3f 100755 --- a/charts/brigade-project/values.yaml +++ b/charts/brigade-project/values.yaml @@ -12,8 +12,7 @@ cloneURL: "https://github.com/deis/empty-testbed.git" sharedSecret: "IBrakeForSeaBeasts" # OPTIONAL: Use this to have Brigade update your project about the build. -# You probably want this if you want pull requests or commits to show -# the build status. +# This is REQUIRED for the GitHub gateway, but optional otherwise. github: {} # token: "github oauth token" diff --git a/pkg/webhook/dockerhub.go b/pkg/webhook/dockerhub.go index 3e53692e8..74652d685 100644 --- a/pkg/webhook/dockerhub.go +++ b/pkg/webhook/dockerhub.go @@ -63,34 +63,24 @@ func (s *dockerPushHook) Handle(c *gin.Context) { return } - // This will clone the repo before responding to the webhook. We need - // to make sure that this doesn't cause the hook to hang up. - brigadeJS, err := s.getFile(commit, "./brigade.js", proj) - if err != nil { - log.Printf("aborting DockerImagePush event due to error: %s", err) - c.JSON(http.StatusBadRequest, gin.H{"status": "brigadejs not found"}) - return - } - - go s.notifyDockerImagePush(proj, commit, body, brigadeJS) + go s.notifyDockerImagePush(proj, commit, body) c.JSON(200, gin.H{"status": "Success"}) } -func (s *dockerPushHook) notifyDockerImagePush(proj *brigade.Project, commit string, payload, brigadeJS []byte) { - if err := s.doDockerImagePush(proj, commit, payload, brigadeJS); err != nil { +func (s *dockerPushHook) notifyDockerImagePush(proj *brigade.Project, commit string, payload []byte) { + if err := s.doDockerImagePush(proj, commit, payload); err != nil { log.Printf("failed dockerimagepush event: %s", err) } } -func (s *dockerPushHook) doDockerImagePush(proj *brigade.Project, commit string, payload, brigadeJS []byte) error { +func (s *dockerPushHook) doDockerImagePush(proj *brigade.Project, commit string, payload []byte) error { b := &brigade.Build{ ProjectID: proj.ID, Type: "image_push", Provider: "dockerhub", Commit: commit, Payload: payload, - Script: brigadeJS, } return s.store.CreateBuild(b) } diff --git a/pkg/webhook/dockerhub_test.go b/pkg/webhook/dockerhub_test.go index 07895f071..43830e3fc 100644 --- a/pkg/webhook/dockerhub_test.go +++ b/pkg/webhook/dockerhub_test.go @@ -7,11 +7,6 @@ import ( ) func TestDoDockerImagePush(t *testing.T) { - script := `events.dockerhub = function(e) { - if (e.payload.push_data.tag == "latest") { - throw "Unexpected test: " + e.payload.push_data.tag - } - }` proj := &brigade.Project{ ID: "brigade-1234", Name: "org/proj", @@ -32,7 +27,7 @@ func TestDoDockerImagePush(t *testing.T) { hook := NewDockerPushHook(&testStore{}) - if err := hook.doDockerImagePush(proj, commit, []byte(exampleWebhook), []byte(script)); err != nil { + if err := hook.doDockerImagePush(proj, commit, []byte(exampleWebhook)); err != nil { t.Errorf("failed docker image push: %s", err) } }