Class: Fastlane::Actions::JiraReleaseValidationAction

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

Class Method Summary collapse

Class Method Details

.authorsObject



55
56
57
# File 'lib/fastlane/plugin/jira_issues_release_notes/actions/jira_release_validation_action.rb', line 55

def self.authors
  ["Erick Martins"]
end

.available_optionsObject



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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/fastlane/plugin/jira_issues_release_notes/actions/jira_release_validation_action.rb', line 68

def self.available_options
  [
    FastlaneCore::ConfigItem.new(
      key: :tag_prefix,
      description: "Match parameter of git describe. See man page of git describe for more info",
      verify_block: proc do |value|
        UI.user_error!("No match for analyze_commits action given, pass using `match: 'expr'`") unless value && !value.empty?
      end
    ),
    FastlaneCore::ConfigItem.new(
      key: :ticket_prefix,
      env_name: 'FL_FIND_TICKETS_MATCHING',
      description:  'regex to extract ticket numbers',
      default_value: '[A-Z]+',
      optional: true
    ),
    FastlaneCore::ConfigItem.new(
      key: :tag_version_match,
      description: "To parse version number from tag name",
      default_value: '\d+\.\d+\.\d+'
    ),
    FastlaneCore::ConfigItem.new(
      key: :validated_status,
      env_name: 'FL_JIRA_VALIDATED_STATUS',
      description:  'List of jira issues status already validated',
      optional: false,
      type: Array
    ),
    FastlaneCore::ConfigItem.new(
      key: :to_validate_status,
      env_name: 'FL_JIRA_TO_VALIDATE_STATUS',
      description:  'List of jira issues status to be validated',
      optional: false,
      type: Array
    ),
    FastlaneCore::ConfigItem.new(
      key: :format,
      description: "You can use either markdown, slack, html or plain",
      default_value: "markdown",
      optional: true,
      verify_block: proc do |value|
        UI.user_error!("Invalid format! You can use either markdown, slack, html or plain") unless ['markdown', 'html', 'slack', 'plain'].include?(value)
      end
    ),

    # Jira Client options
    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 password',
      optional: false
    ),
    FastlaneCore::ConfigItem.new(
      key: :host,
      env_name: 'FL_JIRA_HOST',
      description:  'Jira location',
      optional: false
    ),
    FastlaneCore::ConfigItem.new(
      key: :api_version,
      env_name: 'FL_JIRA_API_VERSION',
      description:  'Jira api version',
      default_value: '2',
      optional: true,
    ),
    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
    ),
    FastlaneCore::ConfigItem.new(
      key: :debug,
      description: "True if you want to log out a debug info",
      default_value: false,
      type: Boolean,
      optional: true
    )
  ]
end

.descriptionObject



51
52
53
# File 'lib/fastlane/plugin/jira_issues_release_notes/actions/jira_release_validation_action.rb', line 51

def self.description
  "It generates a release note based on the issues keys and descriptions found in the commits"
end

.detailsObject



63
64
65
66
# File 'lib/fastlane/plugin/jira_issues_release_notes/actions/jira_release_validation_action.rb', line 63

def self.details
  # Optional:
  "It generates a release note based on the issues keys and descriptions found in the commits"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


164
165
166
167
168
169
170
# File 'lib/fastlane/plugin/jira_issues_release_notes/actions/jira_release_validation_action.rb', line 164

def self.is_supported?(platform)
  # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
  # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
  #
  # [:ios, :mac, :android].include?(platform)
  true
end

.return_valueObject



59
60
61
# File 'lib/fastlane/plugin/jira_issues_release_notes/actions/jira_release_validation_action.rb', line 59

def self.return_value
  # If your method provides a return value, you can describe here what it does
end

.run(params) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/fastlane/plugin/jira_issues_release_notes/actions/jira_release_validation_action.rb', line 16

def self.run(params)
  Helper::JiraIssuesReleaseNotesHelper.initialize_jira(
    host: params[:host],
    username: params[:username],
    password: params[:password],
    context_path: params[:context_path],
    api_version: params[:api_version],
    disable_ssl_verification: params[:disable_ssl_verification]
  )

  @format = params[:format]
  @format_line_break = @format === 'html' ? '<br />' : "\n"

  issue_key_regex = Regexp.new("(#{params[:ticket_prefix]}-\\d+)")

  issues = Helper::JiraIssuesReleaseNotesHelper.get_issues_from_commit_after_latest_tag(
    tag_regex: params[:tag_prefix],
    tag_version_match: params[:tag_version_match],
    issue_key_regex: issue_key_regex,
    debug: params[:debug]
  )

  return '' unless issues

  grouped_issues = {
    "Tasks to validate" => issues.select { |issue| params[:to_validate_status].include?(issue.status.name) },
    "Validated tasks" => issues.select { |issue| params[:validated_status].include?(issue.status.name) }
  }

  Helper::JiraIssuesReleaseNotesHelper.generate_changelog(
    groups: grouped_issues, 
    line_break_format: @format_line_break
  )
end