Commit 5fe354ef authored by James Lopez's avatar James Lopez

refactored rake task and make build pass

parent 63a950a5
...@@ -183,7 +183,7 @@ spinach:ruby21: ...@@ -183,7 +183,7 @@ spinach:ruby21:
notify:slack: notify:slack:
stage: notifications stage: notifications
script: script:
- bundle exec rake ci:slack:error - bundle exec rake ci:slack:error["#ci-test","Build failed for master/tags"]
when: on_failure when: on_failure
# only: # only:
# - master # - master
......
...@@ -42,8 +42,7 @@ ...@@ -42,8 +42,7 @@
require 'carrierwave/orm/activerecord' require 'carrierwave/orm/activerecord'
require 'file_size_validator' require 'file_size_validator'
class Project < ActiveRecord::Base
lass Project < ActiveRecord::Base
include Gitlab::ConfigHelper include Gitlab::ConfigHelper
include Gitlab::ShellAdapter include Gitlab::ShellAdapter
include Gitlab::VisibilityLevel include Gitlab::VisibilityLevel
......
namespace :ci do namespace :ci do
namespace :slack do namespace :slack do
desc "GitLab CI | Send slack notification on build failure" desc "GitLab CI | Send slack notification on build failure"
task error: :environment do task :error, [:channel, :error] do |t, args|
error_text = 'Build failed for master/tags' next unless !"#{ENV['CI_SLACK_WEBHOOK_URL']}".blank? && args.channel && args.error
Kernel.system "curl -X POST --data-urlencode 'payload={\"channel\": \"#ci-test\", \"username\": \"gitlab-ci\", \"text\": \"#{error_text}\", \"icon_emoji\": \":gitlab:\"}' $CI_SLACK_WEBHOOK_URL" Kernel.system "curl -X POST --data-urlencode 'payload={\"channel\": \"#{args.channel}\", \"username\": \"gitlab-ci\", \"text\": \"#{args.error}\", \"icon_emoji\": \":gitlab:\"}' $CI_SLACK_WEBHOOK_URL"
end end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment