fastlane-plugin-mattermost 1.3 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 93d469bb0a6c1f93e5eae5f264354856fd7e5992adaeed611707b193d7eb070c
4
- data.tar.gz: cf18eef25c0da701d8a1dcf8459b3ad87c1c033e4cbea6ec68597a9e709e86c6
3
+ metadata.gz: c701b3dbc10a3a5253f79e37d69ca4a58a8eb0ebc7fcae8ed6ec455c1be2da37
4
+ data.tar.gz: d8f226d48259e6a78d62a3d6f7074db1d7caf67a4c3d073d5cc3f119964d3bcd
5
5
  SHA512:
6
- metadata.gz: 9693781d6274c9543537557564f2dd0e29f68dd6c4d29c532748095b277e94a612e5d5961fb9d548bd9714d325fb5156cfde56e1fda9e34c39445f7247c694e6
7
- data.tar.gz: b4b90d029e3658654edc75d67ddc17073b90d79fa9f45d1c491430cc605d976351977164e65684a6550627d7b78e480ede0c0933256fc10a04e8cb437fd4e993
6
+ metadata.gz: 5cabb2243dc8536b56a9e01fe8ed968475e4cbc65e6ce8210d487d85d7ccf53b5b2d5d12d24e3cbd843d245da583c63ee814b9fb7da3d47527bb726357dd91c2
7
+ data.tar.gz: 4ea495ccdc0a43227b1666efd7435f763a412abfdabb91f51db428acd0b8fbb5e56e59d14e3c4013ca40a771064284f746bdc947b151ec3754adddfe217a534c
data/README.md CHANGED
@@ -25,23 +25,23 @@ lane :build_android do
25
25
  # Push messages to Mattermost
26
26
  # Minimum params example
27
27
  mattermost(
28
- url: "https://example.mattermost.com/hooks/xxx-generatedkey-xxx", # mandatory
29
- text: "Hello, this is some text\nThis is more text. :tada:", # mandatory
30
- username: "Fastlane Mattermost", # optional
31
- icon_url: "https://www.mattermost.org/wp-content/uploads/2016/04/icon.png" # optional
32
- )
28
+ url: "https://example.mattermost.com/hooks/xxx-generatedkey-xxx", # mandatory
29
+ text: "Hello, this is some text\nThis is more text. :tada:", # mandatory if 'attachments' is not set
30
+ username: "Fastlane Mattermost", # optional
31
+ icon_url: "https://www.mattermost.org/wp-content/uploads/2016/04/icon.png" # optional
32
+ )
33
33
  # Full params example
34
34
  mattermost(
35
- url: "https://example.mattermost.com/hooks/xxx-generatedkey-xxx", # mandatory
36
- text: "Hello, this is some text\nThis is more text. :tada:", # mandatory
37
- username: "Fastlane Mattermost", # optional
38
- icon_url: "https://www.mattermost.org/wp-content/uploads/2016/04/icon.png", # optional
39
- channel: ... , # optional
40
- icon_emoji: ... , # optional
41
- attachments: ... , # optional
42
- props: ... , # optional
43
- type: ... # optional
44
- )
35
+ url: "https://example.mattermost.com/hooks/xxx-generatedkey-xxx", # mandatory
36
+ text: "Hello, this is some text\nThis is more text. :tada:", # mandatory
37
+ username: "Fastlane Mattermost", # optional
38
+ icon_url: "https://www.mattermost.org/wp-content/uploads/2016/04/icon.png", # optional
39
+ channel: ... , # optional
40
+ icon_emoji: ... , # optional
41
+ attachments: [...] , # optional
42
+ props: ... , # optional
43
+ type: ... # optional
44
+ )
45
45
  ```
46
46
 
47
47
  ## About mattermost
@@ -4,10 +4,10 @@ require_relative '../helper/mattermost_helper'
4
4
  DEFAULT_USERNAME = "Fastlane Mattermost"
5
5
  DEFAULT_ICON_URL = "https://www.mattermost.org/wp-content/uploads/2016/04/icon.png"
6
6
 
7
- def is_blank? variable
7
+ def is_set variable
8
8
  str_variable = variable
9
9
  str_variable = variable.strip if variable.class.to_s == "String"
10
- str_variable.nil? || str_variable.empty?
10
+ variable && !(str_variable.nil? || str_variable.empty?)
11
11
  end
12
12
 
13
13
  module Fastlane
@@ -25,15 +25,21 @@ module Fastlane
25
25
  'Content-Type': 'application/json'
26
26
  }
27
27
  body = {
28
- 'text': params[:text],
29
- 'username': (is_blank?(params[:username]) ? DEFAULT_USERNAME : params[:username]),
30
- 'icon_url': (is_blank?(params[:icon_url]) ? DEFAULT_ICON_URL : params[:icon_url])
28
+ 'username': (is_set(params[:username]) ? params[:username] : DEFAULT_USERNAME),
29
+ 'icon_url': (is_set(params[:icon_url]) ? params[:icon_url] : DEFAULT_ICON_URL)
31
30
  }
32
- body.merge!('channel': params[:channel]) if is_blank?(params[:channel])
33
- body.merge!('icon_emoji': params[:icon_emoji]) if is_blank?(params[:icon_emoji])
34
- body.merge!('attachments': params[:attachments]) if is_blank?(params[:attachments])
35
- body.merge!('props': params[:props]) if is_blank?(params[:props])
36
- body.merge!('type': params[:type]) if is_blank?(params[:type])
31
+
32
+ if !is_set(params[:text]) && !is_set(params[:attachments])
33
+ UI.error("You need to set either 'text' or 'attachments'")
34
+ return
35
+ end
36
+
37
+ body.merge!('text': params[:text]) if is_set(params[:text])
38
+ body.merge!('channel': params[:channel]) if is_set(params[:channel])
39
+ body.merge!('icon_emoji': params[:icon_emoji]) if is_set(params[:icon_emoji])
40
+ body.merge!('attachments': params[:attachments]) if is_set(params[:attachments])
41
+ body.merge!('props': params[:props]) if is_set(params[:props])
42
+ body.merge!('type': params[:type]) if is_set(params[:type])
37
43
  http = Net::HTTP.new(uri.host, uri.port)
38
44
  http.use_ssl = (uri.scheme == 'https')
39
45
  request = Net::HTTP::Post.new(uri.request_uri, header)
@@ -41,9 +47,10 @@ module Fastlane
41
47
  response = http.request(request)
42
48
  rescue => exception
43
49
  UI.error("Exception: #{exception}")
44
- ensure
45
- UI.success('Successfully push messages to Mattermost')
50
+ return
46
51
  end
52
+
53
+ UI.success('Successfully push messages to Mattermost')
47
54
  end
48
55
 
49
56
  def self.description
@@ -70,8 +77,9 @@ module Fastlane
70
77
  sensitive: true,
71
78
  description: "Mattermost Incoming Webhooks URL"),
72
79
  FastlaneCore::ConfigItem.new(key: :text,
73
- env_name: "MATTERMOST_WEBHOOKS_PARAMS",
74
- description: "Mattermost Incoming Webhooks Params"),
80
+ env_name: "MATTERMOST_WEBHOOKS_TEXT",
81
+ optional: true,
82
+ description: "Mattermost Incoming Webhooks Text"),
75
83
  FastlaneCore::ConfigItem.new(key: :username,
76
84
  env_name: "MATTERMOST_WEBHOOKS_USERNAME",
77
85
  optional: true,
@@ -91,6 +99,7 @@ module Fastlane
91
99
  FastlaneCore::ConfigItem.new(key: :attachments,
92
100
  env_name: "MATTERMOST_WEBHOOKS_ATTACHMENTS",
93
101
  optional: true,
102
+ skip_type_validation: true,
94
103
  description: "Mattermost Incoming Webhooks Attachments"),
95
104
  FastlaneCore::ConfigItem.new(key: :props,
96
105
  env_name: "MATTERMOST_WEBHOOKS_PROPS",
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module Mattermost
3
- VERSION = "1.3"
3
+ VERSION = "1.3.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-mattermost
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.3'
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - cpfriend1721994
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-02 00:00:00.000000000 Z
11
+ date: 2023-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
@@ -84,16 +84,16 @@ dependencies:
84
84
  name: rubocop
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: 0.49.1
89
+ version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: 0.49.1
96
+ version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rubocop-require_tools
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -148,7 +148,7 @@ files:
148
148
  - lib/fastlane/plugin/mattermost/actions/mattermost_action.rb
149
149
  - lib/fastlane/plugin/mattermost/helper/mattermost_helper.rb
150
150
  - lib/fastlane/plugin/mattermost/version.rb
151
- homepage:
151
+ homepage: https://github.com/cpfriend1721994/fastlane-plugin-mattermost
152
152
  licenses:
153
153
  - MIT
154
154
  metadata: {}
@@ -167,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
167
  - !ruby/object:Gem::Version
168
168
  version: '0'
169
169
  requirements: []
170
- rubygems_version: 3.1.2
170
+ rubygems_version: 3.2.3
171
171
  signing_key:
172
172
  specification_version: 4
173
173
  summary: Fastlane plugin for push messages to Mattermost