diff --git a/main.go b/main.go index 59afb46..77fba2d 100644 --- a/main.go +++ b/main.go @@ -37,10 +37,6 @@ func main() { setupLogger(plugin.LogLevel) - if env("BUILDKITE_PLUGIN_MONOREPO_DIFF_BUILDKITE_PLUGIN_TEST_MODE", "false") == "true" { - return - } - if _, _, err = uploadPipeline(plugin, generatePipeline); err != nil { log.Fatalf("+++ failed to upload pipeline: %v", err) } diff --git a/pipeline_test.go b/pipeline_test.go index 83d6043..b6636ae 100644 --- a/pipeline_test.go +++ b/pipeline_test.go @@ -236,7 +236,7 @@ func TestGeneratePipeline(t *testing.T) { steps := []Step{ { Trigger: "foo-service-pipeline", - Build: Build{Message: "build message"}, + Build: Build{Message: "build message", MetaData: map[string]string{"build_number": "123"}}, SoftFail: true, Notify: []StepNotify{ {Slack: "@adikari"}, @@ -295,6 +295,8 @@ steps: - trigger: foo-service-pipeline build: message: build message + meta_data: + build_number: "123" soft_fail: true notify: - slack: '@adikari' diff --git a/plugin.go b/plugin.go index 37f7f83..64023f9 100644 --- a/plugin.go +++ b/plugin.go @@ -88,11 +88,12 @@ type Agent map[string]string // Build is buildkite build definition type Build struct { - Message string `yaml:"message,omitempty"` - Branch string `yaml:"branch,omitempty"` - Commit string `yaml:"commit,omitempty"` - RawEnv interface{} `json:"env" yaml:",omitempty"` - Env map[string]string `yaml:"env,omitempty"` + Message string `yaml:"message,omitempty"` + Branch string `yaml:"branch,omitempty"` + Commit string `yaml:"commit,omitempty"` + RawEnv interface{} `json:"env" yaml:",omitempty"` + Env map[string]string `yaml:"env,omitempty"` + MetaData map[string]string `json:"meta_data,omitempty" yaml:"meta_data,omitempty"` // Notify []Notify `yaml:"notify,omitempty"` } diff --git a/plugin_test.go b/plugin_test.go index 2c1f45a..40183e2 100644 --- a/plugin_test.go +++ b/plugin_test.go @@ -75,7 +75,10 @@ func TestPluginShouldUnmarshallCorrectly(t *testing.T) { "config": { "trigger": "service-2", "build": { - "message": "some message" + "message": "some message", + "meta_data": { + "foo": "bar" + } } } }, @@ -182,6 +185,9 @@ func TestPluginShouldUnmarshallCorrectly(t *testing.T) { "env2": "env-2", "env3": "env-3", }, + MetaData: map[string]string{ + "foo": "bar", + }, }, }, }, diff --git a/tests/Dockerfile b/tests/Dockerfile index e8722e7..0a6081b 100644 --- a/tests/Dockerfile +++ b/tests/Dockerfile @@ -6,7 +6,7 @@ COPY . . RUN goreleaser build --rm-dist --skip-validate --config .goreleaser-test.yml -FROM buildkite/plugin-tester +FROM buildkite/plugin-tester:v3.0.1 COPY tests /plugin/tests COPY hooks /plugin/hooks diff --git a/tests/command.bats b/tests/command.bats index b64fec5..a7295fd 100644 --- a/tests/command.bats +++ b/tests/command.bats @@ -1,8 +1,7 @@ #!/usr/bin/env bats -load '/usr/local/lib/bats/load.bash' - setup() { + load "$BATS_PLUGIN_PATH/load.bash" export BUILDKITE_PLUGIN_MONOREPO_DIFF_BUILDKITE_PLUGIN_TEST_MODE="true" stub buildkite-agent pipeline upload @@ -182,7 +181,11 @@ EOM "build": { "message": "some-message", "commit": "commit-hash", - "branch": "go-rewrite" + "branch": "go-rewrite", + "meta_data": { + "build_number": "123", + "build_message": "message" + } }, "async": true, "agents": { @@ -267,6 +270,9 @@ steps: message: some-message branch: go-rewrite commit: commit-hash + meta_data: + build_message: message + build_number: "123" agents: queue: foo-service-queue artifacts: