diff --git a/pipeline.go b/pipeline.go index 58ff27c..332d44f 100644 --- a/pipeline.go +++ b/pipeline.go @@ -104,8 +104,28 @@ func generatePipeline(steps []interface{}, pipelineEnv map[string]string, projec env, foundEnv := stepMap["env"].(map[interface{}]interface{}) _, foundBlockStep := stepMap["block"].(string) + _, foundTriggerStep := stepMap["trigger"].(string) - if !foundBlockStep { + if foundTriggerStep { + // Is there a build property + build, foundBuild := stepMap["build"].(map[interface{}]interface{}) + + if (!foundBuild) { + build = make(map[interface{}]interface{}) // TODO allow nesting + stepMap["build"] = build + } + + buildEnv, foundBuildEnv := build["env"].(map[interface{}]interface{}) + + if (!foundBuildEnv) { + buildEnv = make(map[interface{}]interface{}) + build["env"] = buildEnv // env TODO add to build + } + + for envVarName, envVarValue := range pipelineEnv { + buildEnv[envVarName] = envVarValue + } + } else if !foundBlockStep { if !foundEnv { env = make(map[interface{}]interface{}) stepMap["env"] = env diff --git a/tests/dynamic_pipeline.yml b/tests/dynamic_pipeline.yml index d079fc5..262f44a 100644 --- a/tests/dynamic_pipeline.yml +++ b/tests/dynamic_pipeline.yml @@ -21,6 +21,26 @@ steps: # the same schema as regular buildkite pipeline steps key: bootstrap command: - make bootstrap + - trigger: my-other-build-pipeline + label: trigger-another-pipeline # a non project scoped step (to test depends_on handling) + key: trigger-step + command: + - make trigger-step + - trigger: my-other-build-pipeline + label: trigger-another-pipeline # a non project scoped step (to test depends_on handling) + key: trigger-step + build: + env: + EXISTING_ENV_VAR: persisted + command: + - make trigger-step + - trigger: my-other-build-pipeline + label: trigger-another-pipeline # a non project scoped step (to test depends_on handling) + key: trigger-step + build: + message: 'has existing build key' + command: + - make trigger-step - label: test key: test env: diff --git a/tests/post-command.bats b/tests/post-command.bats index 543c754..797f8d7 100755 --- a/tests/post-command.bats +++ b/tests/post-command.bats @@ -40,6 +40,32 @@ steps: TEST_ENV_PIPELINE: test-pipeline key: bootstrap label: bootstrap +- build: + env: + TEST_ENV_PIPELINE: test-pipeline + command: + - make trigger-step + key: trigger-step + label: trigger-another-pipeline + trigger: my-other-build-pipeline +- build: + env: + EXISTING_ENV_VAR: persisted + TEST_ENV_PIPELINE: test-pipeline + command: + - make trigger-step + key: trigger-step + label: trigger-another-pipeline + trigger: my-other-build-pipeline +- build: + env: + TEST_ENV_PIPELINE: test-pipeline + message: has existing build key + command: + - make trigger-step + key: trigger-step + label: trigger-another-pipeline + trigger: my-other-build-pipeline - command: - cd \$\$BUILDPIPE_PROJECT_PATH - make test