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
60 61 62 |
# File 'lib/fastlane/plugin/mattermost/actions/mattermost_action.rb', line 60 def self. ["cpfriend1721994"] end |
.available_options ⇒ Object
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 |
# File 'lib/fastlane/plugin/mattermost/actions/mattermost_action.rb', line 73 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_TEXT", optional: true, description: "Mattermost Incoming Webhooks Text"), 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, skip_type_validation: 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
56 57 58 |
# File 'lib/fastlane/plugin/mattermost/actions/mattermost_action.rb', line 56 def self.description "Fastlane plugin for push messages to Mattermost" end |
.details ⇒ Object
68 69 70 71 |
# File 'lib/fastlane/plugin/mattermost/actions/mattermost_action.rb', line 68 def self.details # Optional: "Fastlane plugin for push messages to Mattermost" end |
.example_code ⇒ Object
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/fastlane/plugin/mattermost/actions/mattermost_action.rb', line 123 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
115 116 117 118 119 120 121 |
# File 'lib/fastlane/plugin/mattermost/actions/mattermost_action.rb', line 115 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
64 65 66 |
# File 'lib/fastlane/plugin/mattermost/actions/mattermost_action.rb', line 64 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 50 51 52 53 54 |
# 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 = { 'username': (is_set(params[:username]) ? params[:username] : DEFAULT_USERNAME), 'icon_url': (is_set(params[:icon_url]) ? params[:icon_url] : DEFAULT_ICON_URL) } if !is_set(params[:text]) && !is_set(params[:attachments]) UI.error("You need to set either 'text' or 'attachments'") return end body.merge!('text': params[:text]) if is_set(params[:text]) body.merge!('channel': params[:channel]) if is_set(params[:channel]) body.merge!('icon_emoji': params[:icon_emoji]) if is_set(params[:icon_emoji]) body.merge!('attachments': params[:attachments]) if is_set(params[:attachments]) body.merge!('props': params[:props]) if is_set(params[:props]) body.merge!('type': params[:type]) if is_set(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}") return end UI.success('Successfully push messages to Mattermost') end |