buildkite-builder 4.1.1 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +30 -0
- data/VERSION +1 -1
- data/lib/buildkite/builder/loaders/templates.rb +14 -3
- data/lib/buildkite/pipelines/command.rb +24 -12
- data/lib/buildkite/pipelines/helpers/retry.rb +24 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0de0ca71b799a2ae9a8e7c58a853ba4b77fef220b333f5f4d1d790e79c93af3e
|
4
|
+
data.tar.gz: 633bd86958bc6155e30be2fcf62f1ca12b6c6d9c2eb96a5698f2dadaa020b036
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37ad92f7df9fa06f81423968c4c040cb629a39a7bf00cd48fc53bce1d8439f5c551cdbe80c9efba92954592dad696a957d144c4da26a9ba8b2c1747528672ff7
|
7
|
+
data.tar.gz: e63a9f02c24f60f27e2bb23d71ee24543349f2a860810b4fb7e1a21e3b615fd96054acf72f04902632bccbd02274dc58cf5d225b5cac538693ed6d7439b7bced
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,33 @@
|
|
1
|
+
### 4.2.0
|
2
|
+
* Add shared global templates
|
3
|
+
|
4
|
+
### 4.1.2
|
5
|
+
* Raise error with stderr/stdout message when `buildkite-agent` command failed while using bang commands (`artifact!`, `annotate!`, `pipeline!`, and `meta_data!`)
|
6
|
+
* Add `signal_reason` as an automatic retry option
|
7
|
+
|
8
|
+
### 4.1.1
|
9
|
+
* Fix `PluginManager`'s error message when plugin was not registered
|
10
|
+
|
11
|
+
### 4.1.0
|
12
|
+
* Remove `skip` step since it's only mimicing `command` step with a skip.
|
13
|
+
|
14
|
+
### 4.0.0
|
15
|
+
* Remove `subpipeline` since it's not a Buildkite standard.
|
16
|
+
* Refactor template handling
|
17
|
+
* Simplify `group` step implementation
|
18
|
+
|
19
|
+
### 3.9.0
|
20
|
+
* Create a `Plugins` extension to take care named plugins from the plugin manager.
|
21
|
+
|
22
|
+
### 3.8.1...3.8.3
|
23
|
+
* Expose extension manager to be accessible in dsl
|
24
|
+
* Removes an extra definition of `attr_reader :extensions` in pipeline
|
25
|
+
* Allow `group` steps to be able to use extension's dsl methods
|
26
|
+
* Show buildkite builder version at the beginning of the command
|
27
|
+
|
28
|
+
### 3.8.0
|
29
|
+
* Extensions can now take block as argument [example](https://github.com/Gusto/buildkite-builder/blob/v3.8.0/.buildkite/pipelines/showcase/pipeline.rb#L6-L13)
|
30
|
+
|
1
31
|
## 3.6.0
|
2
32
|
* `Buildkite::Pipelines::Command#run` now uses `Open3.capture3` to run system commands, and accepts an optional arg `capture`. When `capture` is true, it returns the stdout of the command. `capture` is true for the meta_data subcommands `get` and `keys` and for the artifact subcommands `shasum` and `search`.
|
3
33
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
4.
|
1
|
+
4.2.0
|
@@ -9,16 +9,27 @@ module Buildkite
|
|
9
9
|
TEMPLATES_PATH = Pathname.new('templates').freeze
|
10
10
|
|
11
11
|
def load
|
12
|
-
|
12
|
+
load_from_path(global_path)
|
13
|
+
load_from_path(pipeline_path)
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def load_from_path(path)
|
19
|
+
return unless path.directory?
|
13
20
|
|
14
|
-
|
21
|
+
path.children.sort.each do |file|
|
15
22
|
add(file.basename('.rb'), load_definition(file, Definition::Template))
|
16
23
|
end
|
17
24
|
end
|
18
25
|
|
19
|
-
def
|
26
|
+
def pipeline_path
|
20
27
|
root.join(TEMPLATES_PATH)
|
21
28
|
end
|
29
|
+
|
30
|
+
def global_path
|
31
|
+
buildkite_path.join(TEMPLATES_PATH)
|
32
|
+
end
|
22
33
|
end
|
23
34
|
end
|
24
35
|
end
|
@@ -5,6 +5,8 @@ require 'open3'
|
|
5
5
|
module Buildkite
|
6
6
|
module Pipelines
|
7
7
|
class Command
|
8
|
+
class CommandFailedError < StandardError; end
|
9
|
+
|
8
10
|
BIN_PATH = 'buildkite-agent'
|
9
11
|
COMMANDS = %w(
|
10
12
|
pipeline
|
@@ -14,36 +16,38 @@ module Buildkite
|
|
14
16
|
)
|
15
17
|
|
16
18
|
class << self
|
17
|
-
def pipeline(subcommand, *args)
|
18
|
-
new(:pipeline, subcommand, *args).run
|
19
|
+
def pipeline(subcommand, *args, exception: false)
|
20
|
+
new(:pipeline, subcommand, *args).run(exception: exception)
|
19
21
|
end
|
20
22
|
|
21
|
-
def artifact(subcommand, *args)
|
23
|
+
def artifact(subcommand, *args, exception: false)
|
22
24
|
capture = case subcommand.to_s
|
23
25
|
when 'shasum', 'search' then true
|
24
26
|
else false
|
25
27
|
end
|
26
28
|
|
27
|
-
new(:artifact, subcommand, *args).run(capture: capture)
|
29
|
+
new(:artifact, subcommand, *args).run(capture: capture, exception: exception)
|
28
30
|
end
|
29
31
|
|
30
|
-
def annotate(body, *args)
|
31
|
-
new(:annotate, body, *args).run
|
32
|
+
def annotate(body, *args, exception: false)
|
33
|
+
new(:annotate, body, *args).run(exception: exception)
|
32
34
|
end
|
33
35
|
|
34
|
-
def meta_data(subcommand, *args)
|
36
|
+
def meta_data(subcommand, *args, exception: false)
|
35
37
|
capture = case subcommand.to_s
|
36
38
|
when 'get', 'keys' then true
|
37
39
|
else false
|
38
40
|
end
|
39
41
|
|
40
|
-
new(:'meta-data', subcommand, *args).run(capture: capture)
|
42
|
+
new(:'meta-data', subcommand, *args).run(capture: capture, exception: exception)
|
41
43
|
end
|
42
44
|
end
|
43
45
|
|
44
46
|
COMMANDS.each do |command|
|
45
47
|
define_singleton_method("#{command}!") do |*args|
|
46
|
-
|
48
|
+
public_send(command, *args, exception: true)
|
49
|
+
rescue CommandFailedError => e
|
50
|
+
abort e.message
|
47
51
|
end
|
48
52
|
end
|
49
53
|
|
@@ -54,9 +58,17 @@ module Buildkite
|
|
54
58
|
@args = transform_args(args)
|
55
59
|
end
|
56
60
|
|
57
|
-
def run(capture: false)
|
58
|
-
stdout,
|
59
|
-
capture
|
61
|
+
def run(capture: false, exception: false)
|
62
|
+
stdout, stderr, status = Open3.capture3(*to_a)
|
63
|
+
if capture
|
64
|
+
stdout
|
65
|
+
elsif status.success?
|
66
|
+
true
|
67
|
+
elsif exception
|
68
|
+
raise CommandFailedError, "#{stdout}\n#{stderr}"
|
69
|
+
else
|
70
|
+
false
|
71
|
+
end
|
60
72
|
end
|
61
73
|
|
62
74
|
private
|
@@ -4,15 +4,36 @@ module Buildkite
|
|
4
4
|
module Pipelines
|
5
5
|
module Helpers
|
6
6
|
module Retry
|
7
|
-
def automatic_retry_on(exit_status
|
7
|
+
def automatic_retry_on(exit_status: nil, limit: nil, signal_reason: nil)
|
8
|
+
raise 'limit must set for `automatic_retry_on`.' unless limit
|
9
|
+
|
10
|
+
if exit_status.nil? && signal_reason.nil?
|
11
|
+
raise 'signal_reason or exit_status must set for `automatic_retry_on`.'
|
12
|
+
end
|
13
|
+
|
8
14
|
retry_value = get(:retry) || set(:retry, {})
|
9
15
|
|
10
16
|
unless retry_value[:automatic].is_a?(Array)
|
11
17
|
retry_value[:automatic] = []
|
12
18
|
end
|
13
19
|
|
14
|
-
|
15
|
-
|
20
|
+
automatic_options = { limit: limit }
|
21
|
+
|
22
|
+
if exit_status && signal_reason
|
23
|
+
retry_value[:automatic].delete_if do |rule|
|
24
|
+
rule[:exit_status] == exit_status && rule[:signal_reason] == signal_reason
|
25
|
+
end
|
26
|
+
automatic_options[:exit_status] = exit_status
|
27
|
+
automatic_options[:signal_reason] = signal_reason
|
28
|
+
elsif exit_status
|
29
|
+
retry_value[:automatic].delete_if { |rule| rule[:exit_status] == exit_status }
|
30
|
+
automatic_options[:exit_status] = exit_status
|
31
|
+
elsif signal_reason
|
32
|
+
retry_value[:automatic].delete_if { |rule| rule[:signal_reason] == signal_reason }
|
33
|
+
automatic_options[:signal_reason] = signal_reason
|
34
|
+
end
|
35
|
+
|
36
|
+
retry_value[:automatic].push(automatic_options)
|
16
37
|
end
|
17
38
|
|
18
39
|
def automatic_retry(enabled)
|
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: 4.
|
4
|
+
version: 4.2.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:
|
12
|
+
date: 2023-06-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rainbow
|
@@ -174,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
174
174
|
- !ruby/object:Gem::Version
|
175
175
|
version: '0'
|
176
176
|
requirements: []
|
177
|
-
rubygems_version: 3.
|
177
|
+
rubygems_version: 3.4.10
|
178
178
|
signing_key:
|
179
179
|
specification_version: 4
|
180
180
|
summary: A gem for programmatically creating Buildkite pipelines.
|