fastlane-plugin-mattermost 1.3.1 → 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: 8a6ce14080c474420332e09866867696f02dd154a7dda144f084e98fa8efb0b8
4
- data.tar.gz: 1044ecf0bf0acbcf8b6f4935285ecf01f374f35eb18bafeec9420cea63be3fd2
3
+ metadata.gz: c701b3dbc10a3a5253f79e37d69ca4a58a8eb0ebc7fcae8ed6ec455c1be2da37
4
+ data.tar.gz: d8f226d48259e6a78d62a3d6f7074db1d7caf67a4c3d073d5cc3f119964d3bcd
5
5
  SHA512:
6
- metadata.gz: 4572a7cb2d28a7df22e3fb957fdce2ba09a5e89dcbc8772b84e5b221d25f09ef4d0f5f0149003ef2f3dea595920c217bbab586313d9e58b11089a2aa2929834a
7
- data.tar.gz: db47dac6786d5138910c3d3f04409c52d58f34ecf13fd6d9f8ef0c823fc13f8ad4070d15d035b412c9c7c3db4be10757115db580d81aa8ab682cd84dae668954
6
+ metadata.gz: 5cabb2243dc8536b56a9e01fe8ed968475e4cbc65e6ce8210d487d85d7ccf53b5b2d5d12d24e3cbd843d245da583c63ee814b9fb7da3d47527bb726357dd91c2
7
+ data.tar.gz: 4ea495ccdc0a43227b1666efd7435f763a412abfdabb91f51db428acd0b8fbb5e56e59d14e3c4013ca40a771064284f746bdc947b151ec3754adddfe217a534c
data/README.md CHANGED
@@ -26,7 +26,7 @@ lane :build_android do
26
26
  # Minimum params example
27
27
  mattermost(
28
28
  url: "https://example.mattermost.com/hooks/xxx-generatedkey-xxx", # mandatory
29
- text: "Hello, this is some text\nThis is more text. :tada:", # mandatory
29
+ text: "Hello, this is some text\nThis is more text. :tada:", # mandatory if 'attachments' is not set
30
30
  username: "Fastlane Mattermost", # optional
31
31
  icon_url: "https://www.mattermost.org/wp-content/uploads/2016/04/icon.png" # optional
32
32
  )
@@ -38,7 +38,7 @@ lane :build_android do
38
38
  icon_url: "https://www.mattermost.org/wp-content/uploads/2016/04/icon.png", # optional
39
39
  channel: ... , # optional
40
40
  icon_emoji: ... , # optional
41
- attachments: ... , # optional
41
+ attachments: [...] , # optional
42
42
  props: ... , # optional
43
43
  type: ... # optional
44
44
  )
@@ -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.1"
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.1
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-05 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
@@ -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