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
53 54 55 |
# File 'lib/fastlane/plugin/mattermost/actions/mattermost_action.rb', line 53 def self. ["cpfriend1721994"] end |
.available_options ⇒ Object
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 |
# File 'lib/fastlane/plugin/mattermost/actions/mattermost_action.rb', line 66 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"), FastlaneCore::ConfigItem.new(key: :channel, env_name: "MATTERMOST_WEBHOOKS_CHANNEL", optional: true, description: "Mattermost Incoming Webhooks Channel"), FastlaneCore::ConfigItem.new(key: :icon_emoji, env_name: "MATTERMOST_WEBHOOKS_ICON_EMOJI", optional: true, description: "Mattermost Incoming Webhooks Icon Emoji"), FastlaneCore::ConfigItem.new(key: :attachments, env_name: "MATTERMOST_WEBHOOKS_ATTACHMENTS", optional: true, description: "Mattermost Incoming Webhooks Attachments"), FastlaneCore::ConfigItem.new(key: :props, env_name: "MATTERMOST_WEBHOOKS_PROPS", optional: true, description: "Mattermost Incoming Webhooks Properties"), FastlaneCore::ConfigItem.new(key: :type, env_name: "MATTERMOST_WEBHOOKS_TYPE", optional: true, description: "Mattermost Incoming Webhooks Type") ] end |
.description ⇒ Object
49 50 51 |
# File 'lib/fastlane/plugin/mattermost/actions/mattermost_action.rb', line 49 def self.description "Fastlane plugin for push messages to Mattermost" end |
.details ⇒ Object
61 62 63 64 |
# File 'lib/fastlane/plugin/mattermost/actions/mattermost_action.rb', line 61 def self.details # Optional: "Fastlane plugin for push messages to Mattermost" end |
.example_code ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/fastlane/plugin/mattermost/actions/mattermost_action.rb', line 114 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" )', '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", channel: ... , icon_emoji: ... , attachments: ... , props: ... , type: ... )' ] end |
.is_supported?(platform) ⇒ Boolean
106 107 108 109 110 111 112 |
# File 'lib/fastlane/plugin/mattermost/actions/mattermost_action.rb', line 106 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
57 58 59 |
# File 'lib/fastlane/plugin/mattermost/actions/mattermost_action.rb', line 57 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 |
# File 'lib/fastlane/plugin/mattermost/actions/mattermost_action.rb', line 16 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': (is_blank?(params[:username]) ? DEFAULT_USERNAME : params[:username]), 'icon_url': (is_blank?(params[:icon_url]) ? DEFAULT_ICON_URL : params[:icon_url]) } body.merge!('channel': params[:channel]) if is_blank?(params[:channel]) body.merge!('icon_emoji': params[:icon_emoji]) if is_blank?(params[:icon_emoji]) body.merge!('attachments': params[:attachments]) if is_blank?(params[:attachments]) body.merge!('props': params[:props]) if is_blank?(params[:props]) body.merge!('type': params[:type]) if is_blank?(params[:type]) 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 |