Class: Fastlane::Actions::BitbucketListDefaultReviewersAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/bitbucket_cloud/actions/bitbucket_list_defaults_reviewers.rb

Class Method Summary collapse

Class Method Details

.authorsObject



48
49
50
# File 'lib/fastlane/plugin/bitbucket_cloud/actions/bitbucket_list_defaults_reviewers.rb', line 48

def self.authors
  ['Luca Tagliabue']
end

.available_optionsObject

rubocop:disable Metrics/MethodLength



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/fastlane/plugin/bitbucket_cloud/actions/bitbucket_list_defaults_reviewers.rb', line 53

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :username,
                                 env_name: 'FL_POST_BITBUCKET_PULL_REQUEST_USERNAME',
                                 description: 'Bitbucket username',
                                 sensitive: true,
                                 type: String,
                                 optional: false,
                                 verify_block: ->(value) { verify_option(key: 'username', value: value) }),
    FastlaneCore::ConfigItem.new(key: :password,
                                 env_name: 'FL_POST_BITBUCKET_PULL_REQUEST_PASSWORD',
                                 description: 'Bitbucket password',
                                 sensitive: true,
                                 type: String,
                                 optional: false,
                                 verify_block: ->(value) { verify_option(key: 'password', value: value) }),
    FastlaneCore::ConfigItem.new(key: :company_host_name,
                                 env_name: 'FL_POST_BITBUCKET_PULL_REQUEST_COMPANY_HOST_NAME',
                                 description: 'Bitbucket company host name',
                                 sensitive: true,
                                 type: String,
                                 optional: false,
                                 verify_block: ->(value) { verify_option(key: 'company_host_name', value: value) }),
    FastlaneCore::ConfigItem.new(key: :repository_name,
                                 env_name: 'FL_POST_BITBUCKET_PULL_REQUEST_REPOSITORY_NAME',
                                 description: 'Bitbucket repository name',
                                 sensitive: true,
                                 type: String,
                                 optional: false,
                                 verify_block: ->(value) { verify_option(key: 'repository_name', value: value) })
  ]
end

.descriptionObject

rubocop:enable Metrics/MethodLength



40
41
42
# File 'lib/fastlane/plugin/bitbucket_cloud/actions/bitbucket_list_defaults_reviewers.rb', line 40

def self.description
  'List of all defaults reviewers of pull requests'
end

.detailsObject



44
45
46
# File 'lib/fastlane/plugin/bitbucket_cloud/actions/bitbucket_list_defaults_reviewers.rb', line 44

def self.details
  'Wrapper of Bitbucket cloud rest apis in order to make easy integration of Bitbucket CI inside fastlane workflow'
end

.example_codeObject



101
102
103
104
105
106
107
108
109
110
# File 'lib/fastlane/plugin/bitbucket_cloud/actions/bitbucket_list_defaults_reviewers.rb', line 101

def self.example_code
  [
    'bitbucket_list_default_reviewers(
        username: "YOUR_USERNAME_HERE",
        password: "YOUR_PASSWORD_HERE",
        company_host_name: "YOUR_COMPANY_HOST_HERE",
        repository_name: "YOUR_REPOSITORY_NAME_HERE"
    )'
  ]
end

.is_supported?(_platform) ⇒ Boolean

Returns:

  • (Boolean)


112
113
114
# File 'lib/fastlane/plugin/bitbucket_cloud/actions/bitbucket_list_defaults_reviewers.rb', line 112

def self.is_supported?(_platform)
  true
end

.outputObject



91
92
93
94
95
# File 'lib/fastlane/plugin/bitbucket_cloud/actions/bitbucket_list_defaults_reviewers.rb', line 91

def self.output
  [
    ['BITBUCKET_LIST_DEFAULT_REVIEWERS_RESULT', 'The result of the bitbucket default-reviewers cloud api']
  ]
end

.return_valueObject



97
98
99
# File 'lib/fastlane/plugin/bitbucket_cloud/actions/bitbucket_list_defaults_reviewers.rb', line 97

def self.return_value
  'The result of the bitbucket default-reviewers cloud api'
end

.run(options) ⇒ Object

rubocop:disable Metrics/MethodLength



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/fastlane/plugin/bitbucket_cloud/actions/bitbucket_list_defaults_reviewers.rb', line 15

def self.run(options)
  require 'excon'

  api_url = Helper::BitbucketCloudHelper.url(company_host_name: options[:company_host_name], repository_name: options[:repository_name], api: 'default-reviewers')

  headers = Helper::BitbucketCloudHelper.headers(username: options[:username], password: options[:password])

  UI.important('Plugin Bitbucket will list all defaults reviewers')

  response = Excon.get(api_url, headers: headers)

  result = Helper::BitbucketCloudHelper.formatted_result(response)

  UI.important('Plugin Bitbucket finished with result')
  UI.important(result.to_s)

  Actions.lane_context[SharedValues::BITBUCKET_LIST_DEFAULT_REVIEWERS_RESULT] = Helper::BitbucketCloudHelper.formatted_context_result(response)

  Helper::BitbucketCloudHelper.check_result(result: result, status: 200)

  UI.success('Successfully list all default reviewers!')
  result
end

.verify_option(options) ⇒ Object

rubocop:enable Metrics/MethodLength



87
88
89
# File 'lib/fastlane/plugin/bitbucket_cloud/actions/bitbucket_list_defaults_reviewers.rb', line 87

def self.verify_option(options)
  UI.user_error!("No value found for '#{options[:key]}'") if options[:value].to_s.empty?
end