Class: Fastlane::Actions::MattermostAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::MattermostAction
- Defined in:
- lib/fastlane/plugin/mattermost/actions/mattermost_action.rb
Class Method Summary collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .example_code ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .return_value ⇒ Object
- .run(params) ⇒ Object
Class Method Details
.authors ⇒ Object
39 40 41 |
# File 'lib/fastlane/plugin/mattermost/actions/mattermost_action.rb', line 39 def self. ["cpfriend1721994"] end |
.available_options ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/fastlane/plugin/mattermost/actions/mattermost_action.rb', line 52 def self. [ FastlaneCore::ConfigItem.new(key: :url, env_name: "MATTERMOST_WEBHOOKS_URL", sensitive: true, description: "Mattermost Incoming Webhooks URL"), FastlaneCore::ConfigItem.new(key: :text, env_name: "MATTERMOST_WEBHOOKS_PARAMS", description: "Mattermost Incoming Webhooks Params"), FastlaneCore::ConfigItem.new(key: :username, env_name: "MATTERMOST_WEBHOOKS_USERNAME", optional: true, description: "Mattermost Incoming Webhooks Username"), FastlaneCore::ConfigItem.new(key: :icon_url, env_name: "MATTERMOST_WEBHOOKS_ICON_URL", optional: true, description: "Mattermost Incoming Webhooks Icon URL") ] end |
.description ⇒ Object
35 36 37 |
# File 'lib/fastlane/plugin/mattermost/actions/mattermost_action.rb', line 35 def self.description "Fastlane plugin for push messages to Mattermost" end |
.details ⇒ Object
47 48 49 50 |
# File 'lib/fastlane/plugin/mattermost/actions/mattermost_action.rb', line 47 def self.details # Optional: "Fastlane plugin for push messages to Mattermost" end |
.example_code ⇒ Object
80 81 82 83 84 85 86 87 88 89 |
# File 'lib/fastlane/plugin/mattermost/actions/mattermost_action.rb', line 80 def self.example_code [ 'mattermost( url: "https://example.mattermost.com/hooks/xxx-generatedkey-xxx", text: "Hello, this is some text\nThis is more text. :tada:", username: "Fastlane Mattermost", icon_url: "https://www.mattermost.org/wp-content/uploads/2016/04/icon.png" )' ] end |
.is_supported?(platform) ⇒ Boolean
72 73 74 75 76 77 78 |
# File 'lib/fastlane/plugin/mattermost/actions/mattermost_action.rb', line 72 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_value ⇒ Object
43 44 45 |
# File 'lib/fastlane/plugin/mattermost/actions/mattermost_action.rb', line 43 def self.return_value # If your method provides a return value, you can describe here what it does 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 32 33 |
# File 'lib/fastlane/plugin/mattermost/actions/mattermost_action.rb', line 7 def self.run(params) require 'net/http' require 'uri' require 'json' begin uri = URI.parse(params[:url]) header = { 'Content-Type': 'application/json' } body = { 'text': params[:text], 'username': ((params[:username].nil? || params[:username].strip.empty?) ? "Fastlane Mattermost" : params[:username]), 'icon_url': ((params[:icon_url].nil? || params[:icon_url].strip.empty?) ? "https://www.mattermost.org/wp-content/uploads/2016/04/icon.png" : params[:icon_url]) } http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = (uri.scheme == 'https') request = Net::HTTP::Post.new(uri.request_uri, header) request.body = body.to_json response = http.request(request) rescue => exception UI.error("Exception: #{exception}") ensure UI.success('Successfully push messages to Mattermost') end end |