Class: Fastlane::Actions::JiraVersionsAction

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

Class Method Summary collapse

Class Method Details

.authorsObject



49
50
51
# File 'lib/fastlane/plugin/jira_issues_release_notes/actions/jira_versions_action.rb', line 49

def self.authors
  ["Erick Martins"]
end

.available_optionsObject



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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/fastlane/plugin/jira_issues_release_notes/actions/jira_versions_action.rb', line 62

def self.available_options
  conflict_extraction_method = Proc.new do |other|
    UI.user_error! "Unexpected conflict with option #{other}" unless [:extract_from_branch, :tag_prefix].include?(other)
  end

  conflict_comment = Proc.new do |other|
    UI.user_error! "Unexpected conflict with option #{other}" unless [:comment_block, :comment].include?(other)
  end

  [
    FastlaneCore::ConfigItem.new(
      key: :project_id,
      env_name: 'FL_JIRA_PROJECT_ID',
      description: 'The project ID or project key',
      optional: false,
    ),
    FastlaneCore::ConfigItem.new(
      key: :query,
      description: 'Filter the results using a literal string. Versions with matching name or description are returned (case insensitive).',
      optional: true,
    ),
    FastlaneCore::ConfigItem.new(
      key: :order_by,
      description: 'Order the results by a field. Valid values: description, -description, +description, name, -name, +name, releaseDate, -releaseDate, +releaseDate, sequence, -sequence, +sequence, startDate, -startDate, +startDate',
      optional: true,
      verify_block: proc do |value|
        valid_order = ["description", "-description", "+description", "name", "-name", "+name", "releaseDate", "-releaseDate", "+releaseDate", "sequence", "-sequence", "+sequence", "startDate", "-startDate", "+startDate"]
        UI.user_error!("Invalid :order_by value! Valid values: #{valid_order.join(", ")}") unless valid_order.include?(value)
      end
    ),
    FastlaneCore::ConfigItem.new(
      key: :status,
      description: 'A list of status values used to filter the results by version status. This parameter accepts a comma-separated list. The status values are released, unreleased, and archived',
      optional: true,
      verify_block: proc do |value|
        valid_values = ["released", "unreleased", "archived"]
        UI.user_error!("Invalid :status value! Valid values: #{valid_values.join(", ")}") unless valid_values.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',
      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: '3',
      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



45
46
47
# File 'lib/fastlane/plugin/jira_issues_release_notes/actions/jira_versions_action.rb', line 45

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

.detailsObject



57
58
59
60
# File 'lib/fastlane/plugin/jira_issues_release_notes/actions/jira_versions_action.rb', line 57

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

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


153
154
155
156
157
158
159
# File 'lib/fastlane/plugin/jira_issues_release_notes/actions/jira_versions_action.rb', line 153

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



53
54
55
# File 'lib/fastlane/plugin/jira_issues_release_notes/actions/jira_versions_action.rb', line 53

def self.return_value
  "boolean value"
end

.run(params) ⇒ Object



15
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
# File 'lib/fastlane/plugin/jira_issues_release_notes/actions/jira_versions_action.rb', line 15

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

  versions = @jira_helper.list_versions(
    project_id_or_key: params[:project_id],
    query: params[:query],
    order_by: params[:order_by],
    status: params[:status]
  )

  versions.map { |version|
    {
      :id => version.self,
      :name => version.name,
      :archived => version.archived,
      :released => version.released,
      :user_release_date => defined? version.userReleaseDate ? version.userReleaseDate : nil,
      :overdue => defined? version.overdue ? version.overdue : false,
      :projectId => version.projectId,
    }
  }
end