From 2900bd4a4e8b6f3d35643174b6bef16a1143f1bb Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Thu, 29 Sep 2022 11:52:32 -0400 Subject: [PATCH] Support both "commands" and "command" key, of any type buildkite allows both of these keys, and allows them as lists of strings in addition to just strings Fixes: #103 --- plugin.go | 5 +++-- tests/command.bats | 10 ++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/plugin.go b/plugin.go index b75b9b5..47dbe4d 100644 --- a/plugin.go +++ b/plugin.go @@ -45,7 +45,8 @@ type Step struct { Trigger string `yaml:"trigger,omitempty"` Label string `yaml:"label,omitempty"` Build Build `yaml:"build,omitempty"` - Command string `yaml:"command,omitempty"` + Command interface{} `yaml:"command,omitempty"` + Commands interface{} `yaml:"commands,omitempty"` Agents Agent `yaml:"agents,omitempty"` Artifacts []string `yaml:"artifacts,omitempty"` RawEnv interface{} `json:"env" yaml:",omitempty"` @@ -172,7 +173,7 @@ func appendEnv(watch *WatchConfig, env map[string]string) { watch.Step.Build.Env, _ = parseEnv(watch.Step.Build.RawEnv) for key, value := range env { - if watch.Step.Command != "" { + if watch.Step.Command != nil || watch.Step.Commands != nil { if watch.Step.Env == nil { watch.Step.Env = make(map[string]string) } diff --git a/tests/command.bats b/tests/command.bats index 19cd06c..2d190d3 100644 --- a/tests/command.bats +++ b/tests/command.bats @@ -164,6 +164,13 @@ EOM "config": { "trigger": "markdown-pipeline" } + }, + + { + "path": "bat-service/", + "config": { + "command": ["echo one", "echo two"] + } } ] } @@ -206,6 +213,9 @@ steps: soft_fail: - exit_status: 1 - exit_status: "255" +- command: + - echo one + - echo two - wait - command: echo "hello world" - command: cat ./foo-file.txt