buildkite-builder 4.5.0 → 4.7.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: c47c9c53151cf213174d4be297b48cc832a92d112c0227eea50ee04f7b8a2951
4
- data.tar.gz: 1d2db37e56f3e5a5dbe13b2cb5b6355fe58a698ef60197ad4bd7d16d07d347cf
3
+ metadata.gz: 483d18ac586fc6073d55347f1385ed50741046001c677201f4a6967b1ecf2357
4
+ data.tar.gz: 5ffa487ec9034858aed6f1e23df31caa291ddfd49c8410bf42e2cde61568d3f9
5
5
  SHA512:
6
- metadata.gz: 256e662ade3a59a9ed2660b8e954781c3cbe995476187e8c186eadbe9e35a0e9c41ac750e5df8afc932c2643df59b99c51bb35b6dc878cddd7f17580e41b17ba
7
- data.tar.gz: 40d109033e53bfc4eb80a4bfb9721cd5569d7fe9c608962da1e9003a0d202c1ff3d3edd7b89f1b6239ba3c7a3108513733abd898f1983491c12dc2fdb8c4d528
6
+ metadata.gz: ffbe3b03a00d903939eba8a21d051c56ceccc910cf0477ada10f14fdddd5ebbbfacf74157aefcf4fdbf4487de46cb4619ddeccc215760dcde665684d33c79d47
7
+ data.tar.gz: 610ae8d5bffc2c413a65ae8083694f619e4ee312914b54de53d486400fb25416ddbdda39334b42fd57d6b8208396570923ae91b9b67935a762c0719ebf9a4e58
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ### 4.6.0
2
+ * Remove `capture` concept on `Buildkite::Pipelines::Command#run` and replaced with `Buildkite::Pipelines::Command::Result` object to represent `Open3.capture3` result.
3
+
1
4
  ### 4.5.0
2
5
  * Do not upload `pipeline.yml` when steps is empty.
3
6
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.5.0
1
+ 4.7.0
@@ -17,7 +17,7 @@ module Buildkite
17
17
  # variables to be set. It also uploads the pipeline to Buildkite.
18
18
  log.info "+++ 🧰 #{'Buildkite Builder'.color(:springgreen)} v#{Buildkite::Builder.version} ─ #{relative_pipeline_path.to_s.yellow}"
19
19
 
20
- if Buildkite::Pipelines::Command.meta_data(:exists, Builder.meta_data.fetch(:job))
20
+ if Buildkite::Pipelines::Command.meta_data(:exists, Builder.meta_data.fetch(:job)).success?
21
21
  log.info "Pipeline already uploaded in #{Buildkite.env.step_id} step".color(:dimgray)
22
22
  else
23
23
  Pipeline.new(pipeline_path, logger: log).upload
@@ -4,8 +4,6 @@ module Buildkite
4
4
  module Builder
5
5
  class Extension
6
6
  class << self
7
- attr_reader :dsl
8
-
9
7
  def dsl(&block)
10
8
  @dsl = Module.new(&block) if block_given?
11
9
  @dsl
@@ -54,8 +54,11 @@ module Buildkite
54
54
  file.write(contents)
55
55
 
56
56
  logger.info "+++ :pipeline: Uploading pipeline"
57
- unless Buildkite::Pipelines::Command.pipeline(:upload, file.path)
58
- logger.info "Pipeline upload failed, saving as artifact…"
57
+
58
+ result = Buildkite::Pipelines::Command.pipeline(:upload, file.path)
59
+
60
+ unless result.success?
61
+ logger.info "Pipeline upload failed with #{result.stderr}, saving as artifact…"
59
62
  Buildkite::Pipelines::Command.artifact!(:upload, file.path)
60
63
  abort
61
64
  end
@@ -7,6 +7,23 @@ module Buildkite
7
7
  class Command
8
8
  class CommandFailedError < StandardError; end
9
9
 
10
+ class Result
11
+ attr_reader :stdout, :stderr
12
+ def initialize(stdout, stderr, status)
13
+ @stdout = stdout.strip
14
+ @stderr = stderr.strip
15
+ @status = status
16
+ end
17
+
18
+ def success?
19
+ @status.success?
20
+ end
21
+
22
+ def output
23
+ @output ||= "#{stdout}\n#{stderr}".strip
24
+ end
25
+ end
26
+
10
27
  BIN_PATH = 'buildkite-agent'
11
28
  COMMANDS = %w(
12
29
  pipeline
@@ -21,12 +38,12 @@ module Buildkite
21
38
  end
22
39
 
23
40
  def artifact(subcommand, *args, exception: false)
24
- capture = case subcommand.to_s
25
- when 'shasum', 'search' then true
26
- else false
27
- end
41
+ result = new(:artifact, subcommand, *args).run(exception: exception)
28
42
 
29
- new(:artifact, subcommand, *args).run(capture: capture, exception: exception)
43
+ case subcommand.to_s
44
+ when 'shasum', 'search' then result.output
45
+ else result
46
+ end
30
47
  end
31
48
 
32
49
  def annotate(body, *args, exception: false)
@@ -34,12 +51,12 @@ module Buildkite
34
51
  end
35
52
 
36
53
  def meta_data(subcommand, *args, exception: false)
37
- capture = case subcommand.to_s
38
- when 'get', 'keys' then true
39
- else false
40
- end
54
+ result = new(:'meta-data', subcommand, *args).run(exception: exception)
41
55
 
42
- new(:'meta-data', subcommand, *args).run(capture: capture, exception: exception)
56
+ case subcommand.to_s
57
+ when 'get', 'keys' then result.output
58
+ else result
59
+ end
43
60
  end
44
61
  end
45
62
 
@@ -58,16 +75,14 @@ module Buildkite
58
75
  @args = transform_args(args)
59
76
  end
60
77
 
61
- def run(capture: false, exception: false)
78
+ def run(exception: false)
62
79
  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}"
80
+ result = Result.new(stdout, stderr, status)
81
+
82
+ if !result.success? && exception
83
+ raise CommandFailedError, "#{result.output}"
69
84
  else
70
- false
85
+ result
71
86
  end
72
87
  end
73
88
 
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.5.0
4
+ version: 4.7.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: 2023-10-31 00:00:00.000000000 Z
12
+ date: 2024-01-08 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.3.13
177
+ rubygems_version: 3.3.26
178
178
  signing_key:
179
179
  specification_version: 4
180
180
  summary: A gem for programmatically creating Buildkite pipelines.