Skip to content

Commit d7e375c

Browse files
authored
Allow notifications (#93)
* Allow notifications * bump version
1 parent d25d553 commit d7e375c

File tree

7 files changed

+20
-8
lines changed

7 files changed

+20
-8
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
0.10.3 (oallenj)
4+
------------------
5+
6+
1. Allow buildpipe to use buildkite's notification.
7+
38
0.10.2 (oallenj)
49
------------------
510

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Example
1515
steps:
1616
- label: ":buildkite:"
1717
plugins:
18-
- jwplayer/buildpipe#v0.10.2:
18+
- jwplayer/buildpipe#v0.10.3:
1919
dynamic_pipeline: dynamic_pipeline.yml
2020
```
2121

hooks/command

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
set -euo pipefail
33

4-
buildpipe_version="${BUILDKITE_PLUGIN_BUILDPIPE_VERSION:-0.10.2}"
4+
buildpipe_version="${BUILDKITE_PLUGIN_BUILDPIPE_VERSION:-0.10.3}"
55
is_test="${BUILDKITE_PLUGIN_BUILDPIPE_TEST_MODE:-false}"
66

77
if [[ "$is_test" == "false" ]]; then

main.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ type Config struct {
1515
Projects []Project `yaml:"projects"`
1616
Steps []interface{} `yaml:"steps"`
1717
Env map[string]string `yaml:"env"`
18+
Notify []interface{} `yaml:"notify"`
1819
}
1920

2021
func NewConfig(filename string) *Config {
@@ -54,7 +55,7 @@ func projectsFromBuildProjects(buildProjects string, projects []Project) []Proje
5455
for _, projectName := range projectNames {
5556
for _, configProject := range projects {
5657
if projectName == configProject.Label {
57-
affectedProjects = append(affectedProjects, configProject)
58+
affectedProjects = append(affectedProjects, configProject)
5859
}
5960
}
6061
}
@@ -71,7 +72,7 @@ func main() {
7172
log.SetLevel(ll)
7273

7374
config := NewConfig(os.Getenv(pluginPrefix + "DYNAMIC_PIPELINE"))
74-
buildProjects := os.Getenv(pluginPrefix+"BUILD_PROJECTS")
75+
buildProjects := os.Getenv(pluginPrefix + "BUILD_PROJECTS")
7576

7677
var affectedProjects []Project
7778
if len(buildProjects) > 0 {
@@ -90,7 +91,7 @@ func main() {
9091
}
9192
}
9293

93-
pipeline := generatePipeline(config.Steps, config.Env, affectedProjects)
94+
pipeline := generatePipeline(config.Steps, config.Notify, config.Env, affectedProjects)
9495

9596
uploadPipeline(*pipeline)
9697
}

pipeline.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import (
1111
)
1212

1313
type Pipeline struct {
14-
Steps []interface{} `yaml:"steps"`
14+
Steps []interface{} `yaml:"steps"`
15+
Notify []interface{} `yaml:"notify,omitempty"`
1516
}
1617

1718
func generateProjectSteps(steps []interface{}, step interface{}, projects []Project) []interface{} {
@@ -92,7 +93,7 @@ func findStepByKey(steps []interface{}, stepKey string) map[interface{}]interfac
9293
return nil
9394
}
9495

95-
func generatePipeline(steps []interface{}, pipelineEnv map[string]string, projects []Project) *Pipeline {
96+
func generatePipeline(steps []interface{}, notify []interface{}, pipelineEnv map[string]string, projects []Project) *Pipeline {
9697
generatedSteps := make([]interface{}, 0)
9798

9899
for _, step := range steps {
@@ -127,7 +128,8 @@ func generatePipeline(steps []interface{}, pipelineEnv map[string]string, projec
127128
}
128129

129130
return &Pipeline{
130-
Steps: generatedSteps,
131+
Steps: generatedSteps,
132+
Notify: notify,
131133
}
132134
}
133135

tests/dynamic_pipeline.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,5 @@ steps: # the same schema as regular buildkite pipeline steps
7373
command:
7474
- cd $$BUILDPIPE_PROJECT_PATH
7575
- make deploy-prod
76+
notify:
77+
- email: "[email protected]"

tests/post-command.bats

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,5 +126,7 @@ steps:
126126
BUILDPIPE_SCOPE: project
127127
TEST_ENV_PIPELINE: test-pipeline
128128
label: deploy-prd project2
129+
notify:
130+
129131
EOM
130132
}

0 commit comments

Comments
 (0)