@@ -124,24 +124,23 @@ namespace :mls_ruby_capistrano_slacker do
124124 puts 'ⓂⓁⓈ-ⓉⒺⒸ [🛠] [mls_ruby_capistrano_slacker] :: [ℹ️] notify_about_beginning'
125125
126126 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 )
127140 Slack ::Notifier . new (
128141 fetch ( :mls_ruby_capistrano_slacker_webhook_url ) ,
129142 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 ]
145144 end
146145 end
147146
@@ -200,7 +199,9 @@ namespace :mls_ruby_capistrano_slacker do
200199 end
201200 end
202201
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
204205 after 'deploy:failed' , 'mls_ruby_capistrano_slacker:notify_failed'
205206 after 'deploy:finished' , 'mls_ruby_capistrano_slacker:notify_finished'
206207end
@@ -211,6 +212,8 @@ namespace :load do
211212 set :mls_ruby_github_url_to_the_project , '<https://github.com/MLSDev/mls_ruby_capistrano_slacker|mls_ruby_capistrano_slacker>'
212213 set :mls_ruby_github_mls_logo , 'https://avatars2.githubusercontent.com/u/1436035?s=50&v=4'
213214 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
214217 set :mls_ruby_gitlab_private_token , ENV [ 'GITLAB__PRIVATE_TOKEN' ]
215218 set :mls_ruby_slack_attachment_fields , -> {
216219 slack_attachment_fields__job = {
0 commit comments