buildkite-builder 4.5.0 → 4.6.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: 4bf8325879836987ca1d33d9822e1c2aaf315843c7ee2b99e5791378a893c767
4
+ data.tar.gz: 2e9edbde3a0db277878a8f307ef0e1975a4dde99c396e87a3ecb1b9b2673b405
5
5
  SHA512:
6
- metadata.gz: 256e662ade3a59a9ed2660b8e954781c3cbe995476187e8c186eadbe9e35a0e9c41ac750e5df8afc932c2643df59b99c51bb35b6dc878cddd7f17580e41b17ba
7
- data.tar.gz: 40d109033e53bfc4eb80a4bfb9721cd5569d7fe9c608962da1e9003a0d202c1ff3d3edd7b89f1b6239ba3c7a3108513733abd898f1983491c12dc2fdb8c4d528
6
+ metadata.gz: bb4cf5652a702e0d030350db16c0447d72cd2000a6cb32fa4f1a89d00c38cc0e5820661ca1fb67de8abe4a56b177172a4a806a4d05ff954744a01dcd2ec56c32
7
+ data.tar.gz: c04110b0ca0f550a4a2be480f9aecde71566358fb9d638a4a0c96d1c503c3de6272a75b78083bb21b60d81a3fc12d4440c80445e5a0f9d41bbae5ea4a130ee30
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.6.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
@@ -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.6.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: 2023-12-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rainbow