buildkite-builder 3.2.0 → 3.3.2

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: d50f76bdcfda9a7561fce2b86dbae5b0ea99d37c0dbd6c763b35541a39e904c8
4
- data.tar.gz: 2fbd91625db37b0bf88546931254b4f4024de25d3d20d09267318eafae2e3646
3
+ metadata.gz: 25e5b7c5ee30bb570f214b7061ecc8c9dee2e118e0116ddfe2cc3d070fb2bed5
4
+ data.tar.gz: a9bad724efa96a3a613eb3c7e3e016c0697d9d4c6e66deba2e09d3056651aad9
5
5
  SHA512:
6
- metadata.gz: 5902b46da66c6ec7828d1bdf4f148f5445f2c7820e9f209e4a7ea22dae1ac8e62ea397660cca1f512737681c4c9397b97d5361f0fd64dba95066cb32751489ad
7
- data.tar.gz: f67169e9bbdb7b84ccc1a6a8fec9593e878b70759e74f7236f595a3772649ce140d3ae99a329e090fb514c9bbbb450d70e58ea6362459404bced23f4a575cab1
6
+ metadata.gz: 6e6758542d63fdfe9b824a5c47765f01ed8ed8aea0130da1249aa9e2f6c7b593ee4bde1ea69b92b897d1ef8e0f1a9df235dddd87a36b0c807496bfefc98ad993
7
+ data.tar.gz: d91ce92070ebacf6b22477c6b16a353578d6c52231c20e6f21f45675ee9e21f889263aa4454b1c5173c069984ae34fbd1b16e9037fdb479ab7cf9447c3cf97e4
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## 3.3.2
2
+ * Fix subpipeline trigger step attributes leak to subpipeline.
3
+
4
+ ## 3.3.1
5
+ * Add support to iterate over subpipelines.
6
+ * Allow build options to be passed to subpipelines.
7
+
8
+ ## 3.3.0
9
+ * Remove arguments in sub-pipeline's trigger step setup and use dsl delegation instead.
10
+
1
11
  ## 3.2.0
2
12
  * Remove `template` from sub-pipeline trigger step setup and use arguments instead.
3
13
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.2.0
1
+ 3.3.2
@@ -9,8 +9,16 @@ module Buildkite
9
9
 
10
10
  attr_reader :data, :name, :dsl
11
11
 
12
- attribute :depends_on, append: true
12
+ # These attributes are for triggered step
13
+ attribute :label
13
14
  attribute :key
15
+ attribute :skip
16
+ attribute :if, as: :condition
17
+ attribute :depends_on, append: true
18
+ attribute :allow_dependency_failure
19
+ attribute :branches
20
+ attribute :async
21
+ attribute :build
14
22
 
15
23
  def self.to_sym
16
24
  name.split('::').last.downcase.to_sym
@@ -37,13 +45,12 @@ module Buildkite
37
45
  end
38
46
 
39
47
  def to_h
40
- attributes = super
41
48
  # Merge envs from main pipeline, since ruby does not have `reverse_merge` and
42
49
  # `data` does not allow keys override, we have to reset the data hash per key.
43
50
  @context.data.env.merge(data.env).each do |key, value|
44
51
  data.env[key] = value
45
52
  end
46
- attributes.merge(data.to_definition)
53
+ data.to_definition
47
54
  end
48
55
 
49
56
  def method_missing(method_name, *args, **kwargs, &_block)
@@ -60,44 +67,38 @@ module Buildkite
60
67
  end
61
68
 
62
69
  dsl do
63
- def pipeline(name, **options, &block)
70
+ def pipeline(name, &block)
64
71
  raise "Subpipeline must have a name" if name.empty?
65
72
  raise "Subpipeline does not allow nested in another Subpipeline" if context.is_a?(Buildkite::Builder::Extensions::SubPipelines::Pipeline)
66
73
 
67
74
  sub_pipeline = Buildkite::Builder::Extensions::SubPipelines::Pipeline.new(name, context, &block)
68
75
  context.data.pipelines.add(sub_pipeline)
69
76
 
70
- options = options.slice(:key, :label, :async, :branches, :condition, :depends_on, :allow_dependency_failure, :skip, :emoji)
71
- options[:key] ||= "subpipeline_#{name}_#{context.data.pipelines.count}"
72
- options[:label] ||= name.capitalize
73
-
74
- if options[:emoji]
75
- emoji = Array(options.delete(:emoji)).map { |name| ":#{name}:" }.join
76
- options[:label] = [emoji, options[:label]].compact.join(' ')
77
- end
78
-
79
- context.data.steps.add(Pipelines::Steps::Trigger, **options) do |context|
80
- key context[:key]
81
- label context[:label]
82
- trigger name
83
- build(
84
- message: '${BUILDKITE_MESSAGE}',
85
- commit: '${BUILDKITE_COMMIT}',
86
- branch: '${BUILDKITE_BRANCH}',
87
- env: {
88
- BUILDKITE_PULL_REQUEST: '${BUILDKITE_PULL_REQUEST}',
89
- BUILDKITE_PULL_REQUEST_BASE_BRANCH: '${BUILDKITE_PULL_REQUEST_BASE_BRANCH}',
90
- BUILDKITE_PULL_REQUEST_REPO: '${BUILDKITE_PULL_REQUEST_REPO}',
91
- BKB_SUBPIPELINE_FILE: sub_pipeline.pipeline_yml
92
- }
93
- )
94
- async context[:async] || false
95
- branches context[:branches] if context[:branches]
96
- condition context[:condition] if context[:condition]
97
- depends_on *context[:depends_on] if context[:depends_on]
98
- allow_dependency_failure context[:allow_dependency_failure] || false
99
- skip context[:skip] || false
100
- end
77
+ trigger_step = context.data.steps.add(Pipelines::Steps::Trigger)
78
+ trigger_step.trigger(name)
79
+
80
+ build_options = {
81
+ message: '${BUILDKITE_MESSAGE}',
82
+ commit: '${BUILDKITE_COMMIT}',
83
+ branch: '${BUILDKITE_BRANCH}',
84
+ env: {
85
+ BUILDKITE_PULL_REQUEST: '${BUILDKITE_PULL_REQUEST}',
86
+ BUILDKITE_PULL_REQUEST_BASE_BRANCH: '${BUILDKITE_PULL_REQUEST_BASE_BRANCH}',
87
+ BUILDKITE_PULL_REQUEST_REPO: '${BUILDKITE_PULL_REQUEST_REPO}',
88
+ BKB_SUBPIPELINE_FILE: sub_pipeline.pipeline_yml
89
+ }
90
+ }
91
+ build_options.merge!(sub_pipeline.build) if sub_pipeline.build
92
+
93
+ trigger_step.build(build_options)
94
+ trigger_step.key(sub_pipeline.key || "subpipeline_#{name}_#{context.data.pipelines.count}")
95
+ trigger_step.label(sub_pipeline.label || name.capitalize)
96
+ trigger_step.async(sub_pipeline.async || false)
97
+ trigger_step.branches(sub_pipeline.branches) if sub_pipeline.branches
98
+ trigger_step.condition(sub_pipeline.condition) if sub_pipeline.condition
99
+ trigger_step.depends_on(*sub_pipeline.get('depends_on')) if sub_pipeline.get('depends_on')
100
+ trigger_step.allow_dependency_failure(sub_pipeline.allow_dependency_failure || false)
101
+ trigger_step.skip(sub_pipeline.skip || false)
101
102
  end
102
103
  end
103
104
  end
@@ -8,6 +8,7 @@ module Buildkite
8
8
  attr_reader :pipelines
9
9
 
10
10
  def_delegator :@pipelines, :count
11
+ def_delegator :@pipelines, :each
11
12
 
12
13
  def initialize(artifacts)
13
14
  @artifacts = artifacts
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.2.0
4
+ version: 3.3.2
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-06-13 00:00:00.000000000 Z
12
+ date: 2022-08-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rainbow
@@ -192,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
192
192
  - !ruby/object:Gem::Version
193
193
  version: '0'
194
194
  requirements: []
195
- rubygems_version: 3.2.32
195
+ rubygems_version: 3.3.13
196
196
  signing_key:
197
197
  specification_version: 4
198
198
  summary: A gem for programmatically creating Buildkite pipelines.