@@ -76,27 +76,66 @@ type StepNotify struct {
7676
7777// Step is buildkite pipeline definition
7878type Step struct {
79- Group string `yaml:"group,omitempty"`
80- Trigger string `yaml:"trigger,omitempty"`
81- Label string `yaml:"label,omitempty"`
82- Branches string `yaml:"branches,omitempty"`
83- Condition string `json:"if,omitempty" yaml:"if,omitempty"`
84- Build Build `yaml:"build,omitempty"`
85- Command interface {} `yaml:"command,omitempty"`
86- Commands interface {} `yaml:"commands,omitempty"`
87- Agents Agent `yaml:"agents,omitempty"`
88- Artifacts []string `yaml:"artifacts,omitempty"`
89- RawEnv interface {} `json:"env" yaml:",omitempty"`
90- Plugins []map [string ]interface {} `json:"plugins,omitempty" yaml:"plugins,omitempty"`
91- Env map [string ]string `yaml:"env,omitempty"`
92- Async bool `yaml:"async,omitempty"`
93- SoftFail interface {} `json:"soft_fail" yaml:"soft_fail,omitempty"`
94- RawNotify []map [string ]interface {} `json:"notify" yaml:",omitempty"`
95- Notify []StepNotify `yaml:"notify,omitempty"`
96- DependsOn interface {} `json:"depends_on" yaml:"depends_on,omitempty"`
97- Key string `yaml:"key,omitempty"`
98- Secrets interface {} `json:"secrets,omitempty" yaml:"secrets,omitempty"`
99- Steps []Step `yaml:"steps,omitempty"`
79+ Group string `yaml:"group,omitempty"`
80+ Trigger string `yaml:"trigger,omitempty"`
81+ Label string `yaml:"label,omitempty"`
82+ Branches string `yaml:"branches,omitempty"`
83+ Condition string `json:"if,omitempty" yaml:"if,omitempty"`
84+ Build Build `yaml:"build,omitempty"`
85+ Command interface {} `yaml:"command,omitempty"`
86+ Commands interface {} `yaml:"commands,omitempty"`
87+ Agents Agent `yaml:"agents,omitempty"`
88+ ArtifactPaths []string `json:"artifact_paths" yaml:"artifact_paths,omitempty"`
89+ RawEnv interface {} `json:"env" yaml:",omitempty"`
90+ Plugins []map [string ]interface {} `json:"plugins,omitempty" yaml:"plugins,omitempty"`
91+ Env map [string ]string `yaml:"env,omitempty"`
92+ Async bool `yaml:"async,omitempty"`
93+ SoftFail interface {} `json:"soft_fail" yaml:"soft_fail,omitempty"`
94+ RawNotify []map [string ]interface {} `json:"notify" yaml:",omitempty"`
95+ Notify []StepNotify `yaml:"notify,omitempty"`
96+ DependsOn interface {} `json:"depends_on" yaml:"depends_on,omitempty"`
97+ Key string `yaml:"key,omitempty"`
98+ Secrets interface {} `json:"secrets,omitempty" yaml:"secrets,omitempty"`
99+ Steps []Step `yaml:"steps,omitempty"`
100+ }
101+
102+ // UnmarshalJSON handles both "artifacts" and "artifact_paths" field names for backward compatibility
103+ // Both fields are supported by the Buildkite API; "artifact_paths" is preferred per documentation
104+ func (step * Step ) UnmarshalJSON (data []byte ) error {
105+ // Check which fields are present without full unmarshaling
106+ var fieldCheck map [string ]json.RawMessage
107+ if err := json .Unmarshal (data , & fieldCheck ); err != nil {
108+ return err
109+ }
110+
111+ _ , hasArtifacts := fieldCheck ["artifacts" ]
112+ _ , hasArtifactPaths := fieldCheck ["artifact_paths" ]
113+
114+ // Validate that both fields are not specified
115+ if hasArtifacts && hasArtifactPaths {
116+ return errors .New ("cannot specify both 'artifacts' and 'artifact_paths'; please use 'artifact_paths'" )
117+ }
118+
119+ // Use a type alias to avoid infinite recursion
120+ type stepAlias Step
121+
122+ // Unmarshal the main struct (this will populate artifact_paths if present)
123+ if err := json .Unmarshal (data , (* stepAlias )(step )); err != nil {
124+ return err
125+ }
126+
127+ // If only "artifacts" was specified, manually extract and use it
128+ if hasArtifacts && ! hasArtifactPaths {
129+ var temp struct {
130+ Artifacts []string `json:"artifacts"`
131+ }
132+ if err := json .Unmarshal (data , & temp ); err != nil {
133+ return err
134+ }
135+ step .ArtifactPaths = temp .Artifacts
136+ }
137+
138+ return nil
100139}
101140
102141// Agent is Buildkite agent definition
@@ -124,7 +163,9 @@ func (plugin *Plugin) UnmarshalJSON(data []byte) error {
124163 Interpolation : true ,
125164 }
126165
127- _ = json .Unmarshal (data , def )
166+ if err := json .Unmarshal (data , def ); err != nil {
167+ return err
168+ }
128169
129170 * plugin = Plugin (* def )
130171
@@ -235,7 +276,7 @@ func initializePlugin(data string) (Plugin, error) {
235276
236277 if err := json .Unmarshal (pluginConfig , & plugin ); err != nil {
237278 log .Debug (err )
238- return Plugin {}, errors . New ( "failed to parse plugin configuration" )
279+ return Plugin {}, err
239280 }
240281
241282 return plugin , nil
0 commit comments