buildkite-builder 3.3.2 → 3.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 25e5b7c5ee30bb570f214b7061ecc8c9dee2e118e0116ddfe2cc3d070fb2bed5
4
- data.tar.gz: a9bad724efa96a3a613eb3c7e3e016c0697d9d4c6e66deba2e09d3056651aad9
3
+ metadata.gz: 64089d229e28dcf07061f4a32178cbf29fc157f2004e03adb84a800f24c2b8fd
4
+ data.tar.gz: d4faa31aac7205a07c29ef2766ae3067079d6d72ddb938adfdcec943babd564c
5
5
  SHA512:
6
- metadata.gz: 6e6758542d63fdfe9b824a5c47765f01ed8ed8aea0130da1249aa9e2f6c7b593ee4bde1ea69b92b897d1ef8e0f1a9df235dddd87a36b0c807496bfefc98ad993
7
- data.tar.gz: d91ce92070ebacf6b22477c6b16a353578d6c52231c20e6f21f45675ee9e21f889263aa4454b1c5173c069984ae34fbd1b16e9037fdb479ab7cf9447c3cf97e4
6
+ metadata.gz: 67c3325a7b86690c80d771a4cf7738718f1d072481cd23a2b21e9cd1bdb9c9a76b96fc35bb270d09c2ca1e69fbbd7e1d81c8b334a6973e4b148a27ebbf98c504
7
+ data.tar.gz: 7f4263163c198d8158fbc93e52dab34369ec51e5957860f4203d602ed6c7e445c018d8cf842584fafbfa2e9d44e0722e0ded99efb754d373bbff96f45bb676c2
data/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ ## 3.5.0
2
+ * `plugin` registrations now takes an optional default attributes hash as the third argument.
3
+
4
+ ## 3.4.1
5
+ * `automatic_retry_on` now overwrites rules with the same exit status.
6
+
7
+ ## 3.4.0
8
+ * `automatically_retry(status:, limit:)` has been renamed to `automatic_retry_on(exit_status:, limit:)`
9
+ * Added `automatic_retry` for setting boolean for `retry.automatic`
10
+ * Added `manual_retry` for setting `retry.manual`
11
+
1
12
  ## 3.3.2
2
13
  * Fix subpipeline trigger step attributes leak to subpipeline.
3
14
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.3.2
1
+ 3.5.0
@@ -21,8 +21,8 @@ module Buildkite
21
21
  context.data.steps.push(Buildkite::Builder::Group.new(label, context.data.steps, &block))
22
22
  end
23
23
 
24
- def plugin(name, uri)
25
- context.data.steps.plugins.add(name, uri)
24
+ def plugin(name, uri, default_attributes = {})
25
+ context.data.steps.plugins.add(name, uri, default_attributes)
26
26
  end
27
27
 
28
28
  def block(template = nil, **args, &block)
@@ -3,16 +3,16 @@
3
3
  module Buildkite
4
4
  module Builder
5
5
  class Plugin
6
- attr_reader :uri, :source, :version, :options
6
+ attr_reader :uri, :source, :version, :attributes
7
7
 
8
- def initialize(uri, options = nil)
8
+ def initialize(uri, attributes = {})
9
9
  @uri = uri
10
10
  @source, @version = uri.split('#')
11
- @options = options
11
+ @attributes = attributes
12
12
  end
13
13
 
14
14
  def to_h
15
- Buildkite::Pipelines::Helpers.sanitize(uri => options)
15
+ Buildkite::Pipelines::Helpers.sanitize(uri => (attributes&.empty? ? nil : attributes))
16
16
  end
17
17
  end
18
18
  end
@@ -8,17 +8,17 @@ module Buildkite
8
8
  @collection = []
9
9
  end
10
10
 
11
- def add(resource, options = nil)
11
+ def add(resource, attributes = {})
12
12
  plugin =
13
13
  case resource
14
14
  when Symbol
15
- uri = plugin_manager.fetch(resource.to_s)
15
+ registered_plugin = plugin_manager.fetch(resource.to_s)
16
16
 
17
- raise ArgumentError, "Plugin `#{resource}` does not exist" unless uri
17
+ raise ArgumentError, "Plugin `#{resource}` does not exist" unless registered_plugin
18
18
 
19
- Plugin.new(uri, options)
19
+ Plugin.new(registered_plugin[:uri], registered_plugin[:default_attributes].merge(attributes))
20
20
  when String
21
- Plugin.new(resource, options)
21
+ Plugin.new(resource, attributes)
22
22
  when Plugin
23
23
  resource
24
24
  else
@@ -5,14 +5,17 @@ module Buildkite
5
5
  @plugins = {}
6
6
  end
7
7
 
8
- def add(name, uri)
8
+ def add(name, uri, default_attributes = {})
9
9
  name = name.to_s
10
10
 
11
11
  if @plugins.key?(name)
12
12
  raise ArgumentError, "Plugin already defined: #{name}"
13
13
  end
14
14
 
15
- @plugins[name] = uri
15
+ @plugins[name] = {
16
+ uri: uri,
17
+ default_attributes: default_attributes
18
+ }
16
19
  end
17
20
 
18
21
  def fetch(name)
@@ -4,9 +4,9 @@ module Buildkite
4
4
  module Pipelines
5
5
  module Helpers
6
6
  module Plugins
7
- def plugin(name_or_source, options = nil)
7
+ def plugin(name_or_source, plugin_attributes = {})
8
8
  attributes['plugins'] ||= Buildkite::Builder::PluginCollection.new(step_collection.plugins)
9
- attributes['plugins'].add(name_or_source, options)
9
+ attributes['plugins'].add(name_or_source, plugin_attributes)
10
10
  end
11
11
 
12
12
  def plugins
@@ -4,15 +4,27 @@ module Buildkite
4
4
  module Pipelines
5
5
  module Helpers
6
6
  module Retry
7
- def automatically_retry(status:, limit:)
8
- retry_value = get(:retry)&.[](:automatic)
7
+ def automatic_retry_on(exit_status:, limit:)
8
+ retry_value = get(:retry) || set(:retry, {})
9
9
 
10
- unless retry_value.is_a?(Array)
11
- retry_value = []
12
- self.retry(automatic: retry_value)
10
+ unless retry_value[:automatic].is_a?(Array)
11
+ retry_value[:automatic] = []
13
12
  end
14
13
 
15
- retry_value.push(exit_status: status, limit: limit)
14
+ retry_value[:automatic].delete_if { |rule| rule[:exit_status] == exit_status }
15
+ retry_value[:automatic].push(exit_status: exit_status, limit: limit)
16
+ end
17
+
18
+ def automatic_retry(enabled)
19
+ retry_value = get(:retry) || set(:retry, {})
20
+ retry_value[:automatic] = enabled
21
+ end
22
+
23
+ def manual_retry(allowed, reason: nil, permit_on_passed: nil)
24
+ retry_value = get(:retry) || set(:retry, {})
25
+ retry_value[:manual] = { allowed: allowed }
26
+ retry_value[:manual][:reason] = reason unless reason.nil?
27
+ retry_value[:manual][:permit_on_passed] = permit_on_passed unless permit_on_passed.nil?
16
28
  end
17
29
  end
18
30
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: buildkite-builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.2
4
+ version: 3.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ngan Pham
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2022-08-22 00:00:00.000000000 Z
12
+ date: 2022-10-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rainbow
@@ -40,21 +40,7 @@ dependencies:
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
42
  - !ruby/object:Gem::Dependency
43
- name: byebug
44
- requirement: !ruby/object:Gem::Requirement
45
- requirements:
46
- - - ">="
47
- - !ruby/object:Gem::Version
48
- version: '0'
49
- type: :development
50
- prerelease: false
51
- version_requirements: !ruby/object:Gem::Requirement
52
- requirements:
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- version: '0'
56
- - !ruby/object:Gem::Dependency
57
- name: pry-byebug
43
+ name: debug
58
44
  requirement: !ruby/object:Gem::Requirement
59
45
  requirements:
60
46
  - - ">="
@@ -185,14 +171,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
185
171
  requirements:
186
172
  - - ">="
187
173
  - !ruby/object:Gem::Version
188
- version: 2.3.0
174
+ version: 3.0.0
189
175
  required_rubygems_version: !ruby/object:Gem::Requirement
190
176
  requirements:
191
177
  - - ">="
192
178
  - !ruby/object:Gem::Version
193
179
  version: '0'
194
180
  requirements: []
195
- rubygems_version: 3.3.13
181
+ rubygems_version: 3.2.32
196
182
  signing_key:
197
183
  specification_version: 4
198
184
  summary: A gem for programmatically creating Buildkite pipelines.