Skip to content

Commit c198441

Browse files
authored
Merge pull request #333 from wordpress-mobile/add/buildkite-build-trigger-action
Add Buildkite Trigger Build Action
2 parents 08602aa + d36f88c commit c198441

File tree

4 files changed

+98
-1
lines changed

4 files changed

+98
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
### New Features
1212

1313
* Introduce new `ios_merge_strings_files` action. [#329]
14+
* Introduce new `buildkite_trigger_build` action. [#333]
1415
* Introduce new `ios_download_strings_files_from_glotpress` action. [#331]
1516

1617
### Bug Fixes

Gemfile.lock

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ PATH
44
fastlane-plugin-wpmreleasetoolkit (2.3.0)
55
activesupport (~> 5)
66
bigdecimal (~> 1.4)
7+
buildkit (~> 1.4)
78
chroma (= 0.2.0)
89
diffy (~> 3.3)
910
git (~> 1.3)
@@ -51,6 +52,8 @@ GEM
5152
aws-eventstream (~> 1, >= 1.0.2)
5253
babosa (1.0.4)
5354
bigdecimal (1.4.4)
55+
buildkit (1.4.5)
56+
sawyer (>= 0.6)
5457
chroma (0.2.0)
5558
claide (1.0.3)
5659
claide-plugins (0.9.2)
@@ -267,6 +270,7 @@ GEM
267270
method_source (0.9.2)
268271
mini_magick (4.11.0)
269272
mini_mime (1.1.2)
273+
mini_portile2 (2.6.1)
270274
minitest (5.14.4)
271275
molinillo (0.8.0)
272276
multi_json (1.15.0)
@@ -276,7 +280,8 @@ GEM
276280
naturally (2.2.1)
277281
netrc (0.11.0)
278282
no_proxy_fix (0.1.2)
279-
nokogiri (1.12.5-x86_64-darwin)
283+
nokogiri (1.12.5)
284+
mini_portile2 (~> 2.6.1)
280285
racc (~> 1.4)
281286
octokit (4.21.0)
282287
faraday (>= 0.9)

fastlane-plugin-wpmreleasetoolkit.gemspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Gem::Specification.new do |spec|
2828
spec.add_dependency 'diffy', '~> 3.3'
2929
spec.add_dependency 'nokogiri', '~> 1.11' # Needed for AndroidLocalizeHelper
3030
spec.add_dependency 'octokit', '~> 4.18'
31+
spec.add_dependency 'buildkit', '~> 1.4'
3132
spec.add_dependency 'git', '~> 1.3'
3233
spec.add_dependency 'jsonlint', '~> 0.3'
3334
spec.add_dependency 'rake', '>= 12.3', '< 14.0'
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
module Fastlane
2+
module Actions
3+
class BuildkiteTriggerBuildAction < Action
4+
def self.run(params)
5+
require 'buildkit'
6+
7+
UI.message "Triggering build on branch #{params[:branch]}, commit #{params[:commit]}, using pipeline from #{params[:pipeline_file]}"
8+
9+
pipeline_name = {
10+
PIPELINE: params[:pipeline_file]
11+
}
12+
13+
client = Buildkit.new(token: params[:buildkite_token])
14+
response = client.create_build(
15+
params[:buildkite_organization],
16+
params[:buildkite_pipeline],
17+
{
18+
branch: params[:branch],
19+
commit: params[:commit],
20+
env: params[:environment].merge(pipeline_name)
21+
}
22+
)
23+
24+
response.state == 'scheduled' ? UI.message('Done!') : UI.crash!("Failed to start job\nError: [#{response}]")
25+
end
26+
27+
#####################################################
28+
# @!group Documentation
29+
#####################################################
30+
31+
def self.description
32+
'Triggers a job on Buildkite'
33+
end
34+
35+
def self.available_options
36+
[
37+
FastlaneCore::ConfigItem.new(
38+
key: :buildkite_token,
39+
env_name: 'BUILDKITE_TOKEN',
40+
description: 'Buildkite Personal Access Token',
41+
type: String,
42+
sensitive: true
43+
),
44+
FastlaneCore::ConfigItem.new(
45+
key: :buildkite_organization,
46+
env_name: 'BUILDKITE_ORGANIZTION',
47+
description: 'The Buildkite organization that contains your pipeline',
48+
type: String
49+
),
50+
FastlaneCore::ConfigItem.new(
51+
key: :buildkite_pipeline,
52+
env_name: 'BUILDKITE_PIPELINE',
53+
description: %(The Buildkite pipeline you'd like to build),
54+
type: String
55+
),
56+
FastlaneCore::ConfigItem.new(
57+
key: :branch,
58+
description: 'The branch you want to build',
59+
type: String
60+
),
61+
FastlaneCore::ConfigItem.new(
62+
key: :commit,
63+
description: 'The commit hash you want to build',
64+
type: String,
65+
default_value: 'HEAD'
66+
),
67+
FastlaneCore::ConfigItem.new(
68+
key: :pipeline_file,
69+
description: 'The name of the pipeline file in the project',
70+
type: String
71+
),
72+
FastlaneCore::ConfigItem.new(
73+
key: :environment,
74+
description: 'Any additional environment variables to provide to the job',
75+
type: Hash,
76+
default_value: {}
77+
),
78+
]
79+
end
80+
81+
def self.authors
82+
['Automattic']
83+
end
84+
85+
def self.is_supported?(platform)
86+
true
87+
end
88+
end
89+
end
90+
end

0 commit comments

Comments
 (0)