fastlane-plugin-slack_message 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: cb44a150bc4c84c5b7806cbebb429dc578dfdbc70175d7d962e468e6b7e461de
4
+ data.tar.gz: dedc9f9e50e383a13a55e5c7332d3829e4f0244b4ee8747bb74da65c5dd5b4b8
5
+ SHA512:
6
+ metadata.gz: 921b8ce98b6e7ff51497e587116407cb6ae30f4d8d5a88028305a8c9baf1b0360fca06724af08cc623f747d18eb67ddb08bf594ff6c68f56255934c95f97a3df
7
+ data.tar.gz: 5885e91ccd9eae87fd9dc208204834ae5e75017f420a7a5633473fd4b8a1db60c4fba67963f2a2b8a531de0d9568486ea33acfca7d78ea340a3b01890f02dee4
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Doruk Kangal <dorukkangal@gmail.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # slack_message plugin
2
+
3
+ [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-slack_message)
4
+
5
+ ## Getting Started
6
+
7
+ This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-slack_message`, add it to your project by running:
8
+
9
+ ```bash
10
+ fastlane add_plugin slack_message
11
+ ```
12
+
13
+ ## About slack_message
14
+
15
+ Send a message to your Slack group
16
+
17
+ This plugin is forked from the Fastlane Slack action. Additionally, it takes thread_timestamp parameter to send the message under a thread.
18
+
19
+ ## Example
20
+
21
+ Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plugin. Try it by cloning the repo, running `fastlane install_plugins` and `bundle exec fastlane test`.
22
+
23
+ ## Run tests for this plugin
24
+
25
+ To run both the tests, and code style validation, run
26
+
27
+ ```
28
+ rake
29
+ ```
30
+
31
+ To automatically fix many of the styling issues, use
32
+ ```
33
+ rubocop -a
34
+ ```
35
+
36
+ ## Issues and Feedback
37
+
38
+ For any other issues and feedback about this plugin, please submit it to this repository.
39
+
40
+ ## Troubleshooting
41
+
42
+ If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
43
+
44
+ ## Using _fastlane_ Plugins
45
+
46
+ For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).
47
+
48
+ ## About _fastlane_
49
+
50
+ _fastlane_ is the easiest way to automate beta deployments and releases for your iOS and Android apps. To learn more, check out [fastlane.tools](https://fastlane.tools).
@@ -0,0 +1,198 @@
1
+ require 'fastlane/action'
2
+ require 'fastlane/actions/slack'
3
+ require_relative '../helper/slack_message_helper'
4
+
5
+ module Fastlane
6
+ module Actions
7
+ class SlackMessageAction < Action
8
+ class Runner
9
+ def initialize(slack_url)
10
+ @webhook_url = slack_url
11
+
12
+ @client = Faraday.new do |conn|
13
+ conn.use(Faraday::Response::RaiseError)
14
+ end
15
+ end
16
+
17
+ def run(options)
18
+
19
+ options[:message] = Fastlane::Actions::SlackAction.trim_message(options[:message].to_s || '')
20
+ options[:message] = Fastlane::Notification::Slack::LinkConverter.convert(options[:message])
21
+
22
+ options[:pretext] = options[:pretext].gsub('\n', "\n") unless options[:pretext].nil?
23
+
24
+ channel = nil
25
+ if options[:channel].to_s.length > 0
26
+ channel = options[:channel]
27
+ channel = ('#' + options[:channel]) unless ['#', '@'].include?(channel[0]) # send message to channel by default
28
+ end
29
+
30
+ username = options[:use_webhook_configured_username_and_icon] ? nil : options[:username]
31
+
32
+ slack_attachment = Fastlane::Actions::SlackAction.generate_slack_attachments(options)
33
+ link_names = options[:link_names]
34
+ icon_url = options[:use_webhook_configured_username_and_icon] ? nil : options[:icon_url]
35
+
36
+ post_message(
37
+ channel: channel,
38
+ thread_timestamp: options[:thread_timestamp],
39
+ username: username,
40
+ attachments: [slack_attachment],
41
+ link_names: link_names,
42
+ icon_url: icon_url,
43
+ fail_on_error: options[:fail_on_error]
44
+ )
45
+ end
46
+
47
+ def post_message(channel:, thread_timestamp:, username:, attachments:, link_names:, icon_url:, fail_on_error:)
48
+ @client.post(@webhook_url) do |request|
49
+ request.headers['Content-Type'] = 'application/json'
50
+ request.body = {
51
+ channel: channel,
52
+ username: username,
53
+ thread_ts: thread_timestamp,
54
+ icon_url: icon_url,
55
+ attachments: attachments,
56
+ link_names: link_names
57
+ }.to_json
58
+ end
59
+ UI.success('Successfully sent Slack notification')
60
+ rescue => error
61
+ UI.error("Exception: #{error}")
62
+ message = "Error pushing Slack message, maybe the integration has no permission to post on this channel? Try removing the channel parameter in your Fastfile, this is usually caused by a misspelled or changed group/channel name or an expired SLACK_URL"
63
+ if fail_on_error
64
+ UI.user_error!(message)
65
+ else
66
+ UI.error(message)
67
+ end
68
+ end
69
+ end
70
+
71
+ def self.run(options)
72
+ Runner.new(options[:slack_url]).run(options)
73
+ end
74
+
75
+ def self.available_options
76
+ [
77
+ FastlaneCore::ConfigItem.new(key: :message,
78
+ env_name: "FL_SLACK_MESSAGE",
79
+ description: "The message that should be displayed on Slack. This supports the standard Slack markup language",
80
+ optional: true),
81
+ FastlaneCore::ConfigItem.new(key: :pretext,
82
+ env_name: "FL_SLACK_PRETEXT",
83
+ description: "This is optional text that appears above the message attachment block. This supports the standard Slack markup language",
84
+ optional: true),
85
+ FastlaneCore::ConfigItem.new(key: :channel,
86
+ env_name: "FL_SLACK_CHANNEL",
87
+ description: "#channel or @username",
88
+ optional: true),
89
+ FastlaneCore::ConfigItem.new(key: :thread_timestamp,
90
+ env_name: "FL_SLACK_THREAD_TIMESTAMP",
91
+ description: "Timestamp of the message to reply",
92
+ optional: true),
93
+ FastlaneCore::ConfigItem.new(key: :slack_url,
94
+ env_name: "SLACK_URL",
95
+ sensitive: true,
96
+ description: "Create an Incoming WebHook for your Slack group",
97
+ verify_block: proc do |value|
98
+ UI.user_error!("Invalid URL, must start with https://") unless value.start_with?("https://")
99
+ end),
100
+ FastlaneCore::ConfigItem.new(key: :username,
101
+ env_name: "FL_SLACK_USERNAME",
102
+ description: "Overrides the webhook's username property if use_webhook_configured_username_and_icon is false",
103
+ default_value: "fastlane",
104
+ optional: true),
105
+ FastlaneCore::ConfigItem.new(key: :use_webhook_configured_username_and_icon,
106
+ env_name: "FL_SLACK_USE_WEBHOOK_CONFIGURED_USERNAME_AND_ICON",
107
+ description: "Use webhook's default username and icon settings? (true/false)",
108
+ default_value: false,
109
+ type: Boolean,
110
+ optional: true),
111
+ FastlaneCore::ConfigItem.new(key: :icon_url,
112
+ env_name: "FL_SLACK_ICON_URL",
113
+ description: "Overrides the webhook's image property if use_webhook_configured_username_and_icon is false",
114
+ default_value: "https://fastlane.tools/assets/img/fastlane_icon.png",
115
+ optional: true),
116
+ FastlaneCore::ConfigItem.new(key: :payload,
117
+ env_name: "FL_SLACK_PAYLOAD",
118
+ description: "Add additional information to this post. payload must be a hash containing any key with any value",
119
+ default_value: {},
120
+ type: Hash),
121
+ FastlaneCore::ConfigItem.new(key: :default_payloads,
122
+ env_name: "FL_SLACK_DEFAULT_PAYLOADS",
123
+ description: "Specifies default payloads to include. Pass an empty array to suppress all the default payloads",
124
+ default_value: ['lane', 'test_result', 'git_branch', 'git_author', 'last_git_commit', 'last_git_commit_hash'],
125
+ type: Array),
126
+ FastlaneCore::ConfigItem.new(key: :attachment_properties,
127
+ env_name: "FL_SLACK_ATTACHMENT_PROPERTIES",
128
+ description: "Merge additional properties in the slack attachment, see https://api.slack.com/docs/attachments",
129
+ default_value: {},
130
+ type: Hash),
131
+ FastlaneCore::ConfigItem.new(key: :success,
132
+ env_name: "FL_SLACK_SUCCESS",
133
+ description: "Was this build successful? (true/false)",
134
+ optional: true,
135
+ default_value: true,
136
+ type: Boolean),
137
+ FastlaneCore::ConfigItem.new(key: :fail_on_error,
138
+ env_name: "FL_SLACK_FAIL_ON_ERROR",
139
+ description: "Should an error sending the slack notification cause a failure? (true/false)",
140
+ optional: true,
141
+ default_value: true,
142
+ type: Boolean),
143
+ FastlaneCore::ConfigItem.new(key: :link_names,
144
+ env_name: "FL_SLACK_LINK_NAMES",
145
+ description: "Find and link channel names and usernames (true/false)",
146
+ optional: true,
147
+ default_value: false,
148
+ type: Boolean)
149
+ ]
150
+ end
151
+
152
+ def self.is_supported?(platform)
153
+ true
154
+ end
155
+
156
+ def self.return_value
157
+ # If your method provides a return value, you can describe here what it does
158
+ end
159
+
160
+ def self.description
161
+ "Send a message to your [Slack](https://slack.com) group"
162
+ end
163
+
164
+ def self.details
165
+ "This plugin is forked from the Fastlane Slack action. Additionally, it takes thread_timestamp parameter to send the message under a thread."
166
+ end
167
+
168
+ def self.authors
169
+ ["Doruk Kangal"]
170
+ end
171
+
172
+ def self.example_code
173
+ [
174
+ 'slack(message: "App successfully released!")',
175
+ 'slack(
176
+ message: "App successfully released!",
177
+ channel: "#channel", # Optional, by default will post to the default channel configured for the POST URL.
178
+ success: true, # Optional, defaults to true.
179
+ payload: { # Optional, lets you specify any number of your own Slack attachments.
180
+ "Build Date" => Time.new.to_s,
181
+ "Built by" => "Jenkins",
182
+ },
183
+ default_payloads: [:git_branch, :git_author], # Optional, lets you specify default payloads to include. Pass an empty array to suppress all the default payloads.
184
+ attachment_properties: { # Optional, lets you specify any other properties available for attachments in the slack API (see https://api.slack.com/docs/attachments).
185
+ # This hash is deep merged with the existing properties set using the other properties above. This allows your own fields properties to be appended to the existing fields that were created using the `payload` property for instance.
186
+ thumb_url: "https://example.com/path/to/thumb.png",
187
+ fields: [{
188
+ title: "My Field",
189
+ value: "My Value",
190
+ short: true
191
+ }]
192
+ }
193
+ )'
194
+ ]
195
+ end
196
+ end
197
+ end
198
+ end
@@ -0,0 +1,16 @@
1
+ require 'fastlane_core/ui/ui'
2
+
3
+ module Fastlane
4
+ UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")
5
+
6
+ module Helper
7
+ class SlackMessageHelper
8
+ # class methods that you define here become available in your action
9
+ # as `Helper::SlackMessageHelper.your_method`
10
+ #
11
+ def self.show_message
12
+ UI.message("Hello from the slack_message plugin helper!")
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,5 @@
1
+ module Fastlane
2
+ module SlackMessage
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,16 @@
1
+ require 'fastlane/plugin/slack_message/version'
2
+
3
+ module Fastlane
4
+ module SlackMessage
5
+ # Return all .rb files inside the "actions" and "helper" directory
6
+ def self.all_classes
7
+ Dir[File.expand_path('**/{actions,helper}/*.rb', File.dirname(__FILE__))]
8
+ end
9
+ end
10
+ end
11
+
12
+ # By default we want to import all available actions and helpers
13
+ # A plugin can contain any number of actions and plugins
14
+ Fastlane::SlackMessage.all_classes.each do |current|
15
+ require current
16
+ end
metadata ADDED
@@ -0,0 +1,188 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fastlane-plugin-slack_message
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Doruk Kangal
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-08-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: fastlane
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 2.209.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 2.209.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec_junit_formatter
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '='
102
+ - !ruby/object:Gem::Version
103
+ version: 1.12.1
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '='
109
+ - !ruby/object:Gem::Version
110
+ version: 1.12.1
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop-performance
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubocop-require_tools
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: simplecov
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ description:
154
+ email: dorukkangal@gmail.com
155
+ executables: []
156
+ extensions: []
157
+ extra_rdoc_files: []
158
+ files:
159
+ - LICENSE
160
+ - README.md
161
+ - lib/fastlane/plugin/slack_message.rb
162
+ - lib/fastlane/plugin/slack_message/actions/slack_message_action.rb
163
+ - lib/fastlane/plugin/slack_message/helper/slack_message_helper.rb
164
+ - lib/fastlane/plugin/slack_message/version.rb
165
+ homepage: https://github.com/dorukkangal/fastlane-plugin-slack_message
166
+ licenses:
167
+ - MIT
168
+ metadata: {}
169
+ post_install_message:
170
+ rdoc_options: []
171
+ require_paths:
172
+ - lib
173
+ required_ruby_version: !ruby/object:Gem::Requirement
174
+ requirements:
175
+ - - ">="
176
+ - !ruby/object:Gem::Version
177
+ version: '2.6'
178
+ required_rubygems_version: !ruby/object:Gem::Requirement
179
+ requirements:
180
+ - - ">="
181
+ - !ruby/object:Gem::Version
182
+ version: '0'
183
+ requirements: []
184
+ rubygems_version: 3.0.3.1
185
+ signing_key:
186
+ specification_version: 4
187
+ summary: Send a message to your Slack group
188
+ test_files: []