Class: Fastlane::Actions::JiraFetchTicketsAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::JiraFetchTicketsAction
- Defined in:
- lib/fastlane/plugin/jira_fetch_tickets/actions/jira_fetch_tickets_action.rb
Class Method Summary collapse
- .append_jql?(options) ⇒ Boolean
- .append_jql_from_array?(options) ⇒ Boolean
- .append_jql_from_string?(options) ⇒ Boolean
- .authors ⇒ Object
-
.available_options ⇒ Object
rubocop:disable Metrics/MethodLength.
-
.description ⇒ Object
rubocop:enable Metrics/PerceivedComplexity rubocop:enable Metrics/CyclomaticComplexity rubocop:enable Metrics/MethodLength.
- .details ⇒ Object
-
.example_code ⇒ Object
rubocop:disable Metrics/MethodLength.
-
.is_supported?(_platform) ⇒ Boolean
rubocop:enable Metrics/MethodLength.
- .jql_from_array?(options) ⇒ Boolean
- .jql_from_string?(options) ⇒ Boolean
- .output ⇒ Object
- .return_value ⇒ Object
-
.run(params) ⇒ Object
rubocop:disable Metrics/PerceivedComplexity rubocop:disable Metrics/CyclomaticComplexity rubocop:disable Metrics/MethodLength.
-
.verify_option(options) ⇒ Object
rubocop:enable Metrics/MethodLength.
Class Method Details
.append_jql?(options) ⇒ Boolean
156 157 158 159 160 161 162 163 164 165 |
# File 'lib/fastlane/plugin/jira_fetch_tickets/actions/jira_fetch_tickets_action.rb', line 156 def self.append_jql?() jql = [:jql] new_value = [:new_value] if jql.empty? new_value else "#{jql} AND #{new_value}" end end |
.append_jql_from_array?(options) ⇒ Boolean
131 132 133 134 135 136 137 |
# File 'lib/fastlane/plugin/jira_fetch_tickets/actions/jira_fetch_tickets_action.rb', line 131 def self.append_jql_from_array?() jql = [:jql] = { key: [:key], values: [:values] } to_append = jql_from_array?() = { jql: jql, new_value: to_append } append_jql?() end |
.append_jql_from_string?(options) ⇒ Boolean
148 149 150 151 152 153 154 |
# File 'lib/fastlane/plugin/jira_fetch_tickets/actions/jira_fetch_tickets_action.rb', line 148 def self.append_jql_from_string?() jql = [:jql] = { key: [:key], value: [:value] } to_append = jql_from_string?() = { jql: jql, new_value: to_append } append_jql?() end |
.authors ⇒ Object
174 175 176 |
# File 'lib/fastlane/plugin/jira_fetch_tickets/actions/jira_fetch_tickets_action.rb', line 174 def self. ['Luca Tagliabue'] end |
.available_options ⇒ Object
rubocop:disable Metrics/MethodLength
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
# File 'lib/fastlane/plugin/jira_fetch_tickets/actions/jira_fetch_tickets_action.rb', line 193 def self. [ FastlaneCore::ConfigItem.new(key: :url, env_name: 'FL_JIRA_SITE', description: 'URL for Jira instance', sensitive: true, type: String, verify_block: ->(value) { verify_option(key: 'url', value: value) }), FastlaneCore::ConfigItem.new(key: :username, env_name: 'FL_JIRA_USERNAME', description: 'Username for Jira instance', sensitive: true, type: String, verify_block: ->(value) { verify_option(key: 'username', value: value) }), FastlaneCore::ConfigItem.new(key: :password, env_name: 'FL_JIRA_PASSWORD', description: 'Password or api token for Jira', sensitive: true, type: String, verify_block: ->(value) { verify_option(key: 'password', value: value) }), FastlaneCore::ConfigItem.new(key: :projects, env_name: 'FL_JIRA_FETCH_JQL_PROJECTS', description: 'Array of Jira projects', type: Array, optional: true), FastlaneCore::ConfigItem.new(key: :project, env_name: 'FL_JIRA_FETCH_JQL_PROJECT', description: 'Jira project', type: String, optional: true, conflicting_options: [:projects], conflict_block: proc do |_other| FastlaneCore::UI.('Ignoring :project in favor of :projects') end), FastlaneCore::ConfigItem.new(key: :statuses, env_name: 'FL_JIRA_FETCH_JQL_STATUSES', description: 'Array of Jira status', type: Array, optional: true), FastlaneCore::ConfigItem.new(key: :status, env_name: 'FL_JIRA_FETCH_JQL_STATUS', description: 'Jira status', type: String, optional: true, conflicting_options: [:statuses], conflict_block: proc do |_other| FastlaneCore::UI.('Ignoring :status in favor of :statuses') end), FastlaneCore::ConfigItem.new(key: :labels, env_name: 'FL_JIRA_FETCH_JQL_LABELS', description: 'Array of Jira labels', type: Array, optional: true), FastlaneCore::ConfigItem.new(key: :label, env_name: 'FL_JIRA_FETCH_JQL_LABEL', description: 'Jira label', type: String, optional: true, conflicting_options: [:labels], conflict_block: proc do |_other| FastlaneCore::UI.('Ignoring :label in favor of :labels') end), FastlaneCore::ConfigItem.new(key: :sprints, env_name: 'FL_JIRA_FETCH_JQL_SPRINTS', description: 'Jira sprints', type: Array, optional: true), FastlaneCore::ConfigItem.new(key: :sprint, env_name: 'FL_JIRA_FETCH_JQL_SPRINT', description: 'Jira sprint', type: String, optional: true, conflicting_options: [:sprints], conflict_block: proc do |_other| FastlaneCore::UI.('Ignoring :sprint in favor of :sprints') end), FastlaneCore::ConfigItem.new(key: :fix_versions, env_name: 'FL_JIRA_FETCH_JQL_FIX_VERSIONS', description: 'Jira fix versions', type: Array, optional: true), FastlaneCore::ConfigItem.new(key: :fix_version, env_name: 'FL_JIRA_FETCH_JQL_FIX_VERSION', description: 'Jira fix version', type: String, optional: true, conflicting_options: [:fix_versions], conflict_block: proc do |_other| FastlaneCore::UI.('Ignoring :fix_version in favor of :fix_versions') end), FastlaneCore::ConfigItem.new(key: :custom_jql, env_name: 'FL_JIRA_FETCH_JQL_CUSTOM', description: 'Jira custom jql', type: String, optional: true) ] end |
.description ⇒ Object
rubocop:enable Metrics/PerceivedComplexity rubocop:enable Metrics/CyclomaticComplexity rubocop:enable Metrics/MethodLength
170 171 172 |
# File 'lib/fastlane/plugin/jira_fetch_tickets/actions/jira_fetch_tickets_action.rb', line 170 def self.description 'Fetch ticekts on jira project using jql query' end |
.details ⇒ Object
188 189 190 |
# File 'lib/fastlane/plugin/jira_fetch_tickets/actions/jira_fetch_tickets_action.rb', line 188 def self.details 'Fetch ticekts on jira project using jql query' end |
.example_code ⇒ Object
rubocop:disable Metrics/MethodLength
297 298 299 300 301 302 303 304 305 306 307 308 309 310 |
# File 'lib/fastlane/plugin/jira_fetch_tickets/actions/jira_fetch_tickets_action.rb', line 297 def self.example_code [ 'jira_fetch_tickets( url: "YOUR_URL_HERE", username: "YOUR_USERNAME_HERE", password: "YOUR_PASSWORD_HERE", project: "YOUR_PROJECT_HERE", status: "STATUS_HERE", label: "LABEL_HERE", sprint: "SPRINT_HERE", custom_jql: "CUSTOM_JQL_HERE" )' ] end |
.is_supported?(_platform) ⇒ Boolean
rubocop:enable Metrics/MethodLength
313 314 315 |
# File 'lib/fastlane/plugin/jira_fetch_tickets/actions/jira_fetch_tickets_action.rb', line 313 def self.is_supported?(_platform) true end |
.jql_from_array?(options) ⇒ Boolean
119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/fastlane/plugin/jira_fetch_tickets/actions/jira_fetch_tickets_action.rb', line 119 def self.jql_from_array?() values = [:values] values = values.map do |string| if string.should_escape "\"#{string}\"" else string.to_s end end "#{options[:key]} in (#{values.join(', ')})" end |
.jql_from_string?(options) ⇒ Boolean
139 140 141 142 143 144 145 146 |
# File 'lib/fastlane/plugin/jira_fetch_tickets/actions/jira_fetch_tickets_action.rb', line 139 def self.jql_from_string?() value = [:value] if value.should_escape "#{options[:key]} = \"#{options[:value]}\"" else "#{options[:key]} = #{options[:value]}" end end |
.output ⇒ Object
182 183 184 185 186 |
# File 'lib/fastlane/plugin/jira_fetch_tickets/actions/jira_fetch_tickets_action.rb', line 182 def self.output [ ['JIRA_FETCH_TICKETS_RESULT', 'Hash object of key and issue.'] ] end |
.return_value ⇒ Object
178 179 180 |
# File 'lib/fastlane/plugin/jira_fetch_tickets/actions/jira_fetch_tickets_action.rb', line 178 def self.return_value 'Hash object of key and issue.' end |
.run(params) ⇒ Object
rubocop:disable Metrics/PerceivedComplexity rubocop:disable Metrics/CyclomaticComplexity rubocop:disable Metrics/MethodLength
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 50 51 52 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 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 |
# File 'lib/fastlane/plugin/jira_fetch_tickets/actions/jira_fetch_tickets_action.rb', line 16 def self.run(params) Actions.verify_gem!('jira-ruby') require 'jira-ruby' client = JIRA::Client.new( username: params[:username], password: params[:password], site: params[:url], context_path: '', auth_type: :basic ) projects = params[:projects] project = params[:project] statuses = params[:statuses] status = params[:status] labels = params[:labels] label = params[:label] sprints = params[:sprints] sprint = params[:sprint] fix_versions = params[:fix_versions] fix_version = params[:fix_version] custom_jql = params[:custom_jql] jql = '' unless projects.instance_of?(NilClass) = { key: 'project', values: projects } jql = jql_from_array?() end if jql.empty? && !project.instance_of?(NilClass) = { key: 'project', value: project } jql = jql_from_string?() end added = false unless statuses.instance_of?(NilClass) = { key: 'status', values: statuses, jql: jql } jql = append_jql_from_array?() added = true end if !added && !status.instance_of?(NilClass) = { key: 'status', value: status, jql: jql } jql = append_jql_from_string?() end added = false unless labels.instance_of?(NilClass) = { key: 'labels', values: labels, jql: jql } jql = append_jql_from_array?() added = true end if !added && !label.instance_of?(NilClass) = { key: 'labels', value: label, jql: jql } jql = append_jql_from_string?() end added = false unless sprints.instance_of?(NilClass) = { key: 'sprint', values: sprints, jql: jql } jql = append_jql_from_array?() added = true end if !added && !sprint.instance_of?(NilClass) = { key: 'sprint', value: sprint, jql: jql } jql = append_jql_from_string?() end added = false unless fix_versions.instance_of?(NilClass) = { key: 'fixversion', values: fix_versions, jql: jql } jql = append_jql_from_array?() added = true end if !added && !fix_version.instance_of?(NilClass) = { key: 'fixversion', value: fix_version, jql: jql } jql = append_jql_from_string?() end if custom_jql = { jql: jql, new_value: custom_jql } jql = append_jql?() end FastlaneCore::UI.("JQL query is '#{jql}'") issues = client.Issue.jql(jql) issues = issues.map do |issue| { key: issue.key, issue: issue.attrs } end Actions.lane_context[SharedValues::JIRA_FETCH_TICKETS_RESULT] = issues FastlaneCore::UI.success('Successfully fetched JIRA tickets!') issues end |
.verify_option(options) ⇒ Object
rubocop:enable Metrics/MethodLength
292 293 294 |
# File 'lib/fastlane/plugin/jira_fetch_tickets/actions/jira_fetch_tickets_action.rb', line 292 def self.verify_option() FastlaneCore::UI.user_error!("No value found for '#{options[:key]}'") if [:value].to_s.empty? end |