fastlane-plugin-bitbucket_cloud 0.3.0 → 0.3.2
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/lib/fastlane/plugin/bitbucket_cloud/actions/bitbucket_create_pull_request.rb +66 -65
- data/lib/fastlane/plugin/bitbucket_cloud/actions/bitbucket_list_defaults_reviewers.rb +42 -43
- data/lib/fastlane/plugin/bitbucket_cloud/helper/bitbucket_cloud_helper.rb +13 -3
- data/lib/fastlane/plugin/bitbucket_cloud/version.rb +3 -1
- data/lib/fastlane/plugin/bitbucket_cloud.rb +2 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 436c43be8735177c7e9be9dd73cd6273f9f5782d8a12b6105cc20250c73ccf83
|
4
|
+
data.tar.gz: 5bf801ac01c13ec8079de24039df8f174c1a08d2a171bb8acabf406ebedb2778
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7939558ef73b229b9c75a13587f35f8b79527afeaf5dd0bd0c1435cd6325225f2ffd4ff4818e7fd8478627f8b9580c3651eeb484b927cc424e6f764911ff4d84
|
7
|
+
data.tar.gz: 74f0cf4111265bf7a80c87eefc887a66f78b36be797f4e64eed4f6c07009701699a0f332877c720887e38ed4cc6db64509ba34d02a31f08279eae6651e725659
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'fastlane/action'
|
2
4
|
require 'fastlane_core'
|
3
5
|
require_relative '../helper/bitbucket_cloud_helper'
|
@@ -9,6 +11,7 @@ module Fastlane
|
|
9
11
|
end
|
10
12
|
|
11
13
|
class BitbucketCreatePullRequestAction < Action
|
14
|
+
# rubocop:disable Metrics/MethodLength
|
12
15
|
def self.run(options)
|
13
16
|
require 'excon'
|
14
17
|
|
@@ -16,25 +19,25 @@ module Fastlane
|
|
16
19
|
description = options[:description]
|
17
20
|
reviewers = options[:reviewers]
|
18
21
|
|
19
|
-
api_url = Helper::BitbucketCloudHelper.url(company_host_name: options[:company_host_name], repository_name: options[:repository_name], api:
|
22
|
+
api_url = Helper::BitbucketCloudHelper.url(company_host_name: options[:company_host_name], repository_name: options[:repository_name], api: 'pullrequests')
|
20
23
|
|
21
24
|
headers = Helper::BitbucketCloudHelper.headers(username: options[:username], password: options[:password])
|
22
25
|
|
23
26
|
payload = {
|
24
27
|
title: options[:title],
|
25
28
|
source: {
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
+
branch: {
|
30
|
+
name: options[:source_branch]
|
31
|
+
}
|
29
32
|
}
|
30
33
|
}
|
31
34
|
|
32
35
|
if destination_branch.instance_of?(NilClass)
|
33
|
-
destination_log =
|
36
|
+
destination_log = ''
|
34
37
|
else
|
35
38
|
destination_obj = {
|
36
39
|
branch: {
|
37
|
-
|
40
|
+
name: destination_branch
|
38
41
|
}
|
39
42
|
}
|
40
43
|
payload[:destination] = destination_obj
|
@@ -42,7 +45,7 @@ module Fastlane
|
|
42
45
|
end
|
43
46
|
|
44
47
|
if description.instance_of?(NilClass)
|
45
|
-
description_log =
|
48
|
+
description_log = ''
|
46
49
|
else
|
47
50
|
payload[:description] = description
|
48
51
|
description_log = " and description '#{description}'"
|
@@ -51,8 +54,7 @@ module Fastlane
|
|
51
54
|
unless reviewers.instance_of?(NilClass)
|
52
55
|
reviewers_obj = reviewers.map do |reviewer|
|
53
56
|
{
|
54
|
-
|
55
|
-
|
57
|
+
uuid: reviewer
|
56
58
|
}
|
57
59
|
end
|
58
60
|
payload[:reviewers] = reviewers_obj
|
@@ -66,108 +68,106 @@ module Fastlane
|
|
66
68
|
|
67
69
|
result = Helper::BitbucketCloudHelper.formatted_result(response)
|
68
70
|
|
69
|
-
UI.important(
|
71
|
+
UI.important('Plugin Bitbucket finished with result')
|
70
72
|
UI.important(result.to_s)
|
71
73
|
|
72
74
|
Actions.lane_context[SharedValues::BITBUCKET_CREATE_PULL_REQUEST_RESULT] = Helper::BitbucketCloudHelper.formatted_context_result(response)
|
73
75
|
|
74
|
-
|
75
|
-
error_message = "Plugin Bitbucket finished with error code #{result[:status]} #{result[:reason_phrase]}"
|
76
|
-
raise StandardError, error_message
|
77
|
-
end
|
76
|
+
Helper::BitbucketCloudHelper.check_result(result: result, status: 201)
|
78
77
|
|
79
|
-
UI.success(
|
80
|
-
|
78
|
+
UI.success('Successfully create a new Bitbucket pull request!')
|
79
|
+
result
|
81
80
|
end
|
81
|
+
# rubocop:enable Metrics/MethodLength
|
82
82
|
|
83
83
|
def self.description
|
84
|
-
|
84
|
+
'Create a new pull request inside your Bitbucket project'
|
85
85
|
end
|
86
86
|
|
87
87
|
def self.details
|
88
|
-
|
88
|
+
'Wrapper of Bitbucket cloud rest apis in order to make easy integration of Bitbucket CI inside fastlane workflow'
|
89
89
|
end
|
90
90
|
|
91
91
|
def self.authors
|
92
|
-
[
|
92
|
+
['Luca Tagliabue']
|
93
93
|
end
|
94
94
|
|
95
|
+
# rubocop:disable Metrics/MethodLength
|
95
96
|
def self.available_options
|
96
97
|
[
|
97
98
|
FastlaneCore::ConfigItem.new(key: :username,
|
98
|
-
env_name:
|
99
|
-
description:
|
99
|
+
env_name: 'FL_POST_BITBUCKET_PULL_REQUEST_USERNAME',
|
100
|
+
description: 'Bitbucket username',
|
100
101
|
sensitive: true,
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
default_value_dynamic: true,
|
105
|
-
optional: false),
|
102
|
+
type: String,
|
103
|
+
optional: false,
|
104
|
+
verify_block: ->(value) { verify_option(key: 'username', value: value) }),
|
106
105
|
FastlaneCore::ConfigItem.new(key: :password,
|
107
|
-
env_name:
|
108
|
-
description:
|
106
|
+
env_name: 'FL_POST_BITBUCKET_PULL_REQUEST_PASSWORD',
|
107
|
+
description: 'Bitbucket password',
|
109
108
|
sensitive: true,
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
default_value_dynamic: true,
|
114
|
-
optional: false),
|
109
|
+
type: String,
|
110
|
+
optional: false,
|
111
|
+
verify_block: ->(value) { verify_option(key: 'password', value: value) }),
|
115
112
|
FastlaneCore::ConfigItem.new(key: :company_host_name,
|
116
|
-
env_name:
|
117
|
-
description:
|
113
|
+
env_name: 'FL_POST_BITBUCKET_PULL_REQUEST_COMPANY_HOST_NAME',
|
114
|
+
description: 'Bitbucket company host name',
|
118
115
|
sensitive: true,
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
default_value_dynamic: true,
|
123
|
-
optional: false),
|
116
|
+
type: String,
|
117
|
+
optional: false,
|
118
|
+
verify_block: ->(value) { verify_option(key: 'company_host_name', value: value) }),
|
124
119
|
FastlaneCore::ConfigItem.new(key: :repository_name,
|
125
|
-
env_name:
|
126
|
-
description:
|
120
|
+
env_name: 'FL_POST_BITBUCKET_PULL_REQUEST_REPOSITORY_NAME',
|
121
|
+
description: 'Bitbucket repository name',
|
127
122
|
sensitive: true,
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
default_value_dynamic: true,
|
132
|
-
optional: false),
|
123
|
+
type: String,
|
124
|
+
optional: false,
|
125
|
+
verify_block: ->(value) { verify_option(key: 'repository_name', value: value) }),
|
133
126
|
FastlaneCore::ConfigItem.new(key: :title,
|
134
|
-
env_name:
|
135
|
-
description:
|
136
|
-
|
137
|
-
optional: false
|
127
|
+
env_name: 'FL_POST_BITBUCKET_PULL_REQUEST_TITLE',
|
128
|
+
description: 'Title of the pull request',
|
129
|
+
type: String,
|
130
|
+
optional: false,
|
131
|
+
verify_block: ->(value) { verify_option(key: 'title', value: value) }),
|
138
132
|
FastlaneCore::ConfigItem.new(key: :description,
|
139
|
-
env_name:
|
140
|
-
description:
|
141
|
-
|
133
|
+
env_name: 'FL_POST_BITBUCKET_PULL_REQUEST_DESCRIPTION',
|
134
|
+
description: 'Description of the pull request',
|
135
|
+
type: String,
|
142
136
|
optional: true),
|
143
137
|
FastlaneCore::ConfigItem.new(key: :reviewers,
|
144
|
-
env_name:
|
145
|
-
description: "List of reviewer's
|
138
|
+
env_name: 'FL_POST_BITBUCKET_PULL_REQUEST_REVIEWERS',
|
139
|
+
description: "List of reviewer's uuids for the pull request. If no reviewers are passed, fails back to default ones",
|
146
140
|
type: Array,
|
147
141
|
optional: true),
|
148
142
|
FastlaneCore::ConfigItem.new(key: :source_branch,
|
149
|
-
env_name:
|
150
|
-
description:
|
151
|
-
|
143
|
+
env_name: 'FL_POST_BITBUCKET_PULL_REQUEST_SOURCE_BRANCH',
|
144
|
+
description: 'Name of the source branch',
|
145
|
+
type: String,
|
152
146
|
optional: false),
|
153
147
|
FastlaneCore::ConfigItem.new(key: :destination_branch,
|
154
|
-
env_name:
|
155
|
-
description:
|
156
|
-
|
148
|
+
env_name: 'FL_POST_BITBUCKET_PULL_REQUEST_DESTINATION_BRANCH',
|
149
|
+
description: 'Name of the destination branch',
|
150
|
+
type: String,
|
157
151
|
optional: true)
|
158
152
|
]
|
159
153
|
end
|
154
|
+
# rubocop:enable Metrics/MethodLength
|
155
|
+
|
156
|
+
def self.verify_option(options)
|
157
|
+
UI.user_error!("No value found for '#{options[:key]}'") if options[:value].to_s.empty?
|
158
|
+
end
|
160
159
|
|
161
160
|
def self.output
|
162
161
|
[
|
163
|
-
['BITBUCKET_CREATE_PULL_REQUEST_RESULT', 'The result of the bitbucket
|
162
|
+
['BITBUCKET_CREATE_PULL_REQUEST_RESULT', 'The result of the bitbucket pullrequests cloud api']
|
164
163
|
]
|
165
164
|
end
|
166
165
|
|
167
166
|
def self.return_value
|
168
|
-
'The result of the bitbucket
|
167
|
+
'The result of the bitbucket pullrequests cloud api'
|
169
168
|
end
|
170
169
|
|
170
|
+
# rubocop:disable Metrics/MethodLength
|
171
171
|
def self.example_code
|
172
172
|
[
|
173
173
|
'bitbucket_create_pull_request(
|
@@ -183,8 +183,9 @@ module Fastlane
|
|
183
183
|
)'
|
184
184
|
]
|
185
185
|
end
|
186
|
+
# rubocop:enable Metrics/MethodLength
|
186
187
|
|
187
|
-
def self.is_supported?(
|
188
|
+
def self.is_supported?(_platform)
|
188
189
|
true
|
189
190
|
end
|
190
191
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'fastlane/action'
|
2
4
|
require 'fastlane_core'
|
3
5
|
require_relative '../helper/bitbucket_cloud_helper'
|
@@ -9,94 +11,91 @@ module Fastlane
|
|
9
11
|
end
|
10
12
|
|
11
13
|
class BitbucketListDefaultReviewersAction < Action
|
14
|
+
# rubocop:disable Metrics/MethodLength
|
12
15
|
def self.run(options)
|
13
16
|
require 'excon'
|
14
17
|
|
15
|
-
api_url = Helper::BitbucketCloudHelper.url(company_host_name: options[:company_host_name], repository_name: options[:repository_name], api:
|
18
|
+
api_url = Helper::BitbucketCloudHelper.url(company_host_name: options[:company_host_name], repository_name: options[:repository_name], api: 'default-reviewers')
|
16
19
|
|
17
20
|
headers = Helper::BitbucketCloudHelper.headers(username: options[:username], password: options[:password])
|
18
21
|
|
19
|
-
UI.important(
|
22
|
+
UI.important('Plugin Bitbucket will list all defaults reviewers')
|
20
23
|
|
21
24
|
response = Excon.get(api_url, headers: headers)
|
22
25
|
|
23
26
|
result = Helper::BitbucketCloudHelper.formatted_result(response)
|
24
27
|
|
25
|
-
UI.important(
|
28
|
+
UI.important('Plugin Bitbucket finished with result')
|
26
29
|
UI.important(result.to_s)
|
27
30
|
|
28
31
|
Actions.lane_context[SharedValues::BITBUCKET_LIST_DEFAULT_REVIEWERS_RESULT] = Helper::BitbucketCloudHelper.formatted_context_result(response)
|
29
32
|
|
30
|
-
|
31
|
-
error_message = "Plugin Bitbucket finished with error code #{result[:status]} #{result[:reason_phrase]}"
|
32
|
-
raise StandardError, error_message
|
33
|
-
end
|
33
|
+
Helper::BitbucketCloudHelper.check_result(result: result, status: 200)
|
34
34
|
|
35
|
-
UI.success(
|
36
|
-
|
35
|
+
UI.success('Successfully list all default reviewers!')
|
36
|
+
result
|
37
37
|
end
|
38
|
+
# rubocop:enable Metrics/MethodLength
|
38
39
|
|
39
40
|
def self.description
|
40
|
-
|
41
|
+
'List of all defaults reviewers of pull requests'
|
41
42
|
end
|
42
43
|
|
43
44
|
def self.details
|
44
|
-
|
45
|
+
'Wrapper of Bitbucket cloud rest apis in order to make easy integration of Bitbucket CI inside fastlane workflow'
|
45
46
|
end
|
46
47
|
|
47
48
|
def self.authors
|
48
|
-
[
|
49
|
+
['Luca Tagliabue']
|
49
50
|
end
|
50
51
|
|
52
|
+
# rubocop:disable Metrics/MethodLength
|
51
53
|
def self.available_options
|
52
54
|
[
|
53
55
|
FastlaneCore::ConfigItem.new(key: :username,
|
54
|
-
env_name:
|
55
|
-
description:
|
56
|
+
env_name: 'FL_POST_BITBUCKET_PULL_REQUEST_USERNAME',
|
57
|
+
description: 'Bitbucket username',
|
56
58
|
sensitive: true,
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
default_value_dynamic: true,
|
61
|
-
optional: false),
|
59
|
+
type: String,
|
60
|
+
optional: false,
|
61
|
+
verify_block: ->(value) { verify_option(key: 'username', value: value) }),
|
62
62
|
FastlaneCore::ConfigItem.new(key: :password,
|
63
|
-
env_name:
|
64
|
-
description:
|
63
|
+
env_name: 'FL_POST_BITBUCKET_PULL_REQUEST_PASSWORD',
|
64
|
+
description: 'Bitbucket password',
|
65
65
|
sensitive: true,
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
default_value_dynamic: true,
|
70
|
-
optional: false),
|
66
|
+
type: String,
|
67
|
+
optional: false,
|
68
|
+
verify_block: ->(value) { verify_option(key: 'password', value: value) }),
|
71
69
|
FastlaneCore::ConfigItem.new(key: :company_host_name,
|
72
|
-
env_name:
|
73
|
-
description:
|
70
|
+
env_name: 'FL_POST_BITBUCKET_PULL_REQUEST_COMPANY_HOST_NAME',
|
71
|
+
description: 'Bitbucket company host name',
|
74
72
|
sensitive: true,
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
default_value_dynamic: true,
|
79
|
-
optional: false),
|
73
|
+
type: String,
|
74
|
+
optional: false,
|
75
|
+
verify_block: ->(value) { verify_option(key: 'company_host_name', value: value) }),
|
80
76
|
FastlaneCore::ConfigItem.new(key: :repository_name,
|
81
|
-
env_name:
|
82
|
-
description:
|
77
|
+
env_name: 'FL_POST_BITBUCKET_PULL_REQUEST_REPOSITORY_NAME',
|
78
|
+
description: 'Bitbucket repository name',
|
83
79
|
sensitive: true,
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
default_value_dynamic: true,
|
88
|
-
optional: false)
|
80
|
+
type: String,
|
81
|
+
optional: false,
|
82
|
+
verify_block: ->(value) { verify_option(key: 'repository_name', value: value) })
|
89
83
|
]
|
90
84
|
end
|
85
|
+
# rubocop:enable Metrics/MethodLength
|
86
|
+
|
87
|
+
def self.verify_option(options)
|
88
|
+
UI.user_error!("No value found for '#{options[:key]}'") if options[:value].to_s.empty?
|
89
|
+
end
|
91
90
|
|
92
91
|
def self.output
|
93
92
|
[
|
94
|
-
['BITBUCKET_LIST_DEFAULT_REVIEWERS_RESULT', 'The result of the bitbucket
|
93
|
+
['BITBUCKET_LIST_DEFAULT_REVIEWERS_RESULT', 'The result of the bitbucket default-reviewers cloud api']
|
95
94
|
]
|
96
95
|
end
|
97
96
|
|
98
97
|
def self.return_value
|
99
|
-
'The result of the bitbucket
|
98
|
+
'The result of the bitbucket default-reviewers cloud api'
|
100
99
|
end
|
101
100
|
|
102
101
|
def self.example_code
|
@@ -110,7 +109,7 @@ module Fastlane
|
|
110
109
|
]
|
111
110
|
end
|
112
111
|
|
113
|
-
def self.is_supported?(
|
112
|
+
def self.is_supported?(_platform)
|
114
113
|
true
|
115
114
|
end
|
116
115
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'fastlane_core/ui/ui'
|
2
4
|
|
3
5
|
module Fastlane
|
@@ -19,15 +21,15 @@ module Fastlane
|
|
19
21
|
def self.headers(options)
|
20
22
|
api_token = Base64.strict_encode64("#{options[:username]}:#{options[:password]}")
|
21
23
|
|
22
|
-
{
|
24
|
+
{ 'Content-Type': 'application/json', Authorization: "Basic #{api_token}" }
|
23
25
|
end
|
24
26
|
|
25
27
|
def self.formatted_result(response)
|
26
28
|
{
|
27
29
|
status: response[:status],
|
28
30
|
reason_phrase: response[:reason_phrase],
|
29
|
-
body: response.body ||
|
30
|
-
json:
|
31
|
+
body: response.body || '',
|
32
|
+
json: parse_json(response.body) || {}
|
31
33
|
}
|
32
34
|
end
|
33
35
|
|
@@ -42,6 +44,14 @@ module Fastlane
|
|
42
44
|
rescue JSON::ParserError
|
43
45
|
nil
|
44
46
|
end
|
47
|
+
|
48
|
+
def self.check_result(options)
|
49
|
+
result = options[:result]
|
50
|
+
return unless result[:status] != options[:status]
|
51
|
+
|
52
|
+
error_message = "Plugin Bitbucket finished with error code #{result[:status]} #{result[:reason_phrase]}"
|
53
|
+
raise StandardError, error_message
|
54
|
+
end
|
45
55
|
end
|
46
56
|
end
|
47
57
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastlane-plugin-bitbucket_cloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luca Tagliabue
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-02-
|
11
|
+
date: 2024-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: lu.tagliabue@reply.it
|