@@ -124,24 +124,23 @@ namespace :mls_ruby_capistrano_slacker do
124
124
puts 'ⓂⓁⓈ-ⓉⒺⒸ [🛠] [mls_ruby_capistrano_slacker] :: [ℹ️] notify_about_beginning'
125
125
126
126
on roles ( :all ) do |host |
127
+ options = {
128
+ color : 'warning' ,
129
+ fallback : 'New deploy has began' ,
130
+ text : '_New deploy has began_' ,
131
+ author_name : ENV . fetch ( 'GITLAB_USER_NAME' ) ,
132
+ author_link : "https://#{ URI . parse ( ENV . fetch ( 'CI_API_V4_URL' ) ) . host } /users/#{ ENV . fetch ( 'GITLAB_USER_LOGIN' ) } " ,
133
+ author_icon : author_icon ,
134
+ fields : fetch ( :mls_ruby_slack_attachment_fields ) ,
135
+ footer : fetch ( :mls_ruby_github_url_to_the_project ) ,
136
+ footer_ico : fetch ( :mls_ruby_github_mls_logo ) ,
137
+ ts : Time . now . to_i
138
+ }
139
+ options . merge ( image_url : image_url ) if fetch ( :mls_ruby_capistrano_slacker_display_display_random_picture )
127
140
Slack ::Notifier . new (
128
141
fetch ( :mls_ruby_capistrano_slacker_webhook_url ) ,
129
142
username : 'CapistranoSlacker' ,
130
- icon_emoji : ':ghost:' ) . post text : '' , attachments : [
131
- {
132
- color : 'warning' ,
133
- fallback : 'New deploy has began' ,
134
- text : '_New deploy has began_' ,
135
- author_name : ENV . fetch ( 'GITLAB_USER_NAME' ) ,
136
- author_link : "https://#{ URI . parse ( ENV . fetch ( 'CI_API_V4_URL' ) ) . host } /users/#{ ENV . fetch ( 'GITLAB_USER_LOGIN' ) } " ,
137
- author_icon : author_icon ,
138
- image_url : image_url ,
139
- fields : fetch ( :mls_ruby_slack_attachment_fields ) ,
140
- footer : fetch ( :mls_ruby_github_url_to_the_project ) ,
141
- footer_ico : fetch ( :mls_ruby_github_mls_logo ) ,
142
- ts : Time . now . to_i
143
- }
144
- ]
143
+ icon_emoji : ':ghost:' ) . post text : '' , attachments : [ options ]
145
144
end
146
145
end
147
146
@@ -200,7 +199,9 @@ namespace :mls_ruby_capistrano_slacker do
200
199
end
201
200
end
202
201
203
- before 'deploy:starting' , 'mls_ruby_capistrano_slacker:notify_about_beginning'
202
+ if fetch ( :mls_ruby_capistrano_slacker_notify_about_beginning )
203
+ before 'deploy:starting' , 'mls_ruby_capistrano_slacker:notify_about_beginning'
204
+ end
204
205
after 'deploy:failed' , 'mls_ruby_capistrano_slacker:notify_failed'
205
206
after 'deploy:finished' , 'mls_ruby_capistrano_slacker:notify_finished'
206
207
end
@@ -211,6 +212,8 @@ namespace :load do
211
212
set :mls_ruby_github_url_to_the_project , '<https://github.com/MLSDev/mls_ruby_capistrano_slacker|mls_ruby_capistrano_slacker>'
212
213
set :mls_ruby_github_mls_logo , 'https://avatars2.githubusercontent.com/u/1436035?s=50&v=4'
213
214
set :mls_ruby_capistrano_slacker_post_release_description , false
215
+ set :mls_ruby_capistrano_slacker_display_display_random_picture , false
216
+ set :mls_ruby_capistrano_slacker_notify_about_beginning , false
214
217
set :mls_ruby_gitlab_private_token , ENV [ 'GITLAB__PRIVATE_TOKEN' ]
215
218
set :mls_ruby_slack_attachment_fields , -> {
216
219
slack_attachment_fields__job = {
0 commit comments