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:
notify:slack:
stage: notifications
script:
- bundle exec rake ci:slack:error
- bundle exec rake ci:slack:error["#ci-test","Build failed for master/tags"]
when: on_failure
# only:
# - master
......
......@@ -42,8 +42,7 @@
require 'carrierwave/orm/activerecord'
require 'file_size_validator'
lass Project < ActiveRecord::Base
class Project < ActiveRecord::Base
include Gitlab::ConfigHelper
include Gitlab::ShellAdapter
include Gitlab::VisibilityLevel
......
namespace :ci do
namespace :slack do
desc "GitLab CI | Send slack notification on build failure"
task error: :environment do
error_text = 'Build failed for master/tags'
Kernel.system "curl -X POST --data-urlencode 'payload={\"channel\": \"#ci-test\", \"username\": \"gitlab-ci\", \"text\": \"#{error_text}\", \"icon_emoji\": \":gitlab:\"}' $CI_SLACK_WEBHOOK_URL"
task :error, [:channel, :error] do |t, args|
next unless !"#{ENV['CI_SLACK_WEBHOOK_URL']}".blank? && args.channel && args.error
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
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