Class: Fastlane::Actions::JiraCommentAction

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

Helpers collapse

Documentation collapse

Class Method Summary collapse

Class Method Details

.authorObject



129
130
131
# File 'lib/fastlane/plugin/cerberus/actions/jira_comment_action.rb', line 129

def self.author
  'Harry Singh <[email protected]>'
end

.available_optionsObject



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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/fastlane/plugin/cerberus/actions/jira_comment_action.rb', line 56

def self.available_options
  [
    FastlaneCore::ConfigItem.new(
      key: :issues,
      env_name: 'FL_JIRA_COMMENT_ISSUES',
      description:  'jira issue keys',
      optional: true,
      default_value: [],
      type: Array
    ),
    FastlaneCore::ConfigItem.new(
      key: :build_number,
      env_name: 'FL_JIRA_COMMENT_BUILD_NUMBER',
      description:  'CI build number',
      optional: true,
      default_value: ENV['BUILD_NUMBER']
    ),
    FastlaneCore::ConfigItem.new(
      key: :build_url,
      env_name: 'FL_JIRA_COMMENT_BUILD_URL',
      description:  'CI build URL',
      optional: true,
      default_value: ENV['BUILD_URL']
    ),
    FastlaneCore::ConfigItem.new(
      key: :app_version,
      env_name: 'FL_JIRA_COMMENT_APP_VERSION',
      description:  'App version',
      optional: false
    ),
    FastlaneCore::ConfigItem.new(
      key: :hockey_url,
      env_name: 'FL_JIRA_COMMENT_HOCKEY_URL',
      description:  'Hockey build url',
      optional: true,
      default_value: Actions.lane_context[SharedValues::HOCKEY_DOWNLOAD_LINK]
    ),
    FastlaneCore::ConfigItem.new(
      key: :username,
      env_name: 'FL_JIRA_USERNAME',
      description:  'Jira user',
      optional: false
    ),
    FastlaneCore::ConfigItem.new(
      key: :password,
      env_name: 'FL_JIRA_PASSWORD',
      description:  'Jira user',
      optional: false
    ),
    FastlaneCore::ConfigItem.new(
      key: :host,
      env_name: 'FL_JIRA_HOST',
      description:  'Jira location',
      optional: false
    ),
    FastlaneCore::ConfigItem.new(
      key: :context_path,
      env_name: 'FL_JIRA_CONTEXT_PATH',
      description:  'Jira context path',
      optional: true,
      default_value: ''
    ),
    FastlaneCore::ConfigItem.new(
      key: :disable_ssl_verification,
      env_name: 'FL_JIRA_DISABLE_SSL_VERIFICATION',
      description:  'Jira SSL Verification mode',
      optional: true,
      default_value: false,
      type: Boolean
    )
  ]
end

.detailsObject



48
49
50
# File 'lib/fastlane/plugin/cerberus/actions/jira_comment_action.rb', line 48

def self.details
  'This action adds comments on Jira issues with the current build number and url of that build'
end

.generate_comment(build_number:, build_url:, app_version:, hockey_url:) ⇒ Object



37
38
39
40
41
42
# File 'lib/fastlane/plugin/cerberus/actions/jira_comment_action.rb', line 37

def self.generate_comment(build_number:, build_url:, app_version:, hockey_url:)
  [
    "Jenkins: [Build ##{build_number}|#{build_url}]",
    "HockeyApp: [Version #{app_version} (#{build_number})|#{hockey_url}]"
  ].join("\n")
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/fastlane/plugin/cerberus/actions/jira_comment_action.rb', line 52

def self.is_supported?(platform)
  platform == :ios
end

.run(params) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/fastlane/plugin/cerberus/actions/jira_comment_action.rb', line 7

def self.run(params)
  issues = params[:issues]
  return if issues.to_a.empty?

  jira_helper = Helper::CerberusHelper.jira_helper(
    host: params[:host],
    username: params[:username],
    password: params[:password],
    context_path: params[:context_path],
    disable_ssl_verification: params[:disable_ssl_verification]
  )
  issues = jira_helper.get(issues: issues)

  comment = generate_comment(
    build_number: params[:build_number],
    build_url: params[:build_url],
    app_version: params[:app_version],
    hockey_url: params[:hockey_url]
  )

  jira_helper.add_comment(
    comment: comment,
    issues: issues
  )
end