--- a/bitbucket/loader.go Sat Jul 22 10:45:04 2017 -0500
+++ b/bitbucket/loader.go Sat Jul 22 11:43:01 2017 -0500
@@ -43,18 +43,18 @@
plan.Stages[0].Tasks = append(plan.Stages[0].Tasks, name)
-func addScript(name, image string, script []string, plan plans.Plan, cfg *config.Config) {
+func addScript(name string, image image, script []string, plan plans.Plan, cfg *config.Config) {
addTask(name, task, plan, cfg)
-func addPipeline(name, defImage string, pipelines []pipeline, cfg *config.Config) {
+func addPipeline(name string, defImage image, pipelines []pipeline, cfg *config.Config) { @@ -67,7 +67,7 @@
for idx, pipeline := range pipelines {
- if pipeline.Steps.Image != "" {
+ if pipeline.Steps.Image.Name != "" { image = pipeline.Steps.Image
@@ -119,7 +119,7 @@
-func addPipelines(base, defImage string, pipelines map[string][]pipeline, cfg *config.Config) {
+func addPipelines(base string, defImage image, pipelines map[string][]pipeline, cfg *config.Config) { for name, branchPipeline := range pipelines {
if len(branchPipeline) > 0 {
name := fmt.Sprintf("%s-%s", base, name)
--- a/bitbucket/types.go Sat Jul 22 10:45:04 2017 -0500
+++ b/bitbucket/types.go Sat Jul 22 11:43:01 2017 -0500
@@ -17,8 +17,48 @@
+ "github.com/go-yaml/yaml" + Name string `yaml:"name"` + Username string `yaml:"username"` + Password string `yaml:"password"` + EMail string `yaml:"email"` +func (i *image) UnmarshalYAML(unmarshal func(interface{}) error) error { + // first check if this is the basic format where it's just a name + err := unmarshal(&name) + // if we got a yaml type error, try to unmarshal it as the struct + if _, ok := err.(*yaml.TypeError); ok { + if err := unmarshal(&raw); err != nil { - Image string `yaml:"image"`
+ Image image `yaml:"image"` Script []string `yaml:"script"`
Services []string `yaml:"services"`
@@ -36,7 +76,7 @@
- Image string `yaml:"image"`
+ Image image `yaml:"image"` Environment []string `yaml:"environment"`
Username string `yaml:"username"`
Password string `yaml:"password"`
@@ -50,12 +90,8 @@
Docker bool `yaml:"docker"`
- Depth int `yaml:"depth"`
type bitbucketPipelines struct {
- Image string `yaml:"image"`
+ Image image `yaml:"image"` Clone clone `yaml:"clone"`
Pipelines pipelines `yaml:"pipelines"`
Definitions definition `yaml:"definitions"`
@@ -75,6 +111,10 @@
+ Depth int `yaml:"depth"` func (c *clone) UnmarshalYAML(unmarshal func(interface{}) error) error {
raw := rawClone{Depth: 50}
--- a/bitbucket/unmarshal_test.go Sat Jul 22 10:45:04 2017 -0500
+++ b/bitbucket/unmarshal_test.go Sat Jul 22 11:43:01 2017 -0500
@@ -43,7 +43,9 @@
expected := bitbucketPipelines{
@@ -91,7 +93,9 @@
expected := bitbucketPipelines{
- Image: "pidgin/builder-debian:stretch",
+ Name: "pidgin/builder-debian:stretch", @@ -109,7 +113,9 @@
"release-2.x.y": []pipeline{
- Image: "pidgin/release-builder:release-2.x.y",
+ Name: "pidgin/release-builder:release-2.x.y", "./autogen.sh --enable-debug",
@@ -163,3 +169,77 @@
Expect(actual).To(Equal(expected))
+func (b *bitbucketSuite) TestUnmarshalComplexGlobalImage(t *testing.T) { + yamlData := `pipelines: + var actual bitbucketPipelines + err := yaml.Unmarshal([]byte(yamlData), &actual) + Expect(err).To(BeNil()) + expected := bitbucketPipelines{ + Expect(actual).To(Equal(expected)) +func (b *bitbucketSuite) TestUnmarshalComplexStepImage(t *testing.T) { + yamlData := `pipelines: + email: test@example.com + var actual bitbucketPipelines + err := yaml.Unmarshal([]byte(yamlData), &actual) + Expect(err).To(BeNil()) + expected := bitbucketPipelines{ + EMail: "test@example.com", + Expect(actual).To(Equal(expected))