summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Lopez <james@jameslopez.es>2016-02-05 11:04:13 +0100
committerJames Lopez <james@jameslopez.es>2016-02-05 11:04:13 +0100
commit0309e0818a9d73af0157ce36b2306d5723e7fb97 (patch)
treefc00e4de4f0c29dded0ec481e803d5cfbd81c2ae
parent70f82cc5ac08c2129f3a10dd1155f43eaecd2e03 (diff)
downloadgitlab-ce-0309e0818a9d73af0157ce36b2306d5723e7fb97.tar.gz
removed slack task and added bash script instead. Updated gitlab-ci config file
-rw-r--r--.gitlab-ci.yml11
-rw-r--r--lib/tasks/ci/slack.rake9
-rwxr-xr-xscripts/notify_slack.sh13
3 files changed, 20 insertions, 13 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 997994485da..290fa120812 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -183,8 +183,11 @@ spinach:ruby21:
notify:slack:
stage: notifications
script:
- - bundle exec rake ci:slack:error["#ci-test","Build failed for master/tags"]
+ - source ./scripts/notify_slack.sh "#ci-test" "Build failed for master/tags!"
when: on_failure
- only:
- - master
- - tags \ No newline at end of file
+ # TODO: uncomment these lines.
+ #only:
+ # - master@gitlab-org/gitlab-ce
+ # - tags@gitlab-org/gitlab-ce
+ # - master@gitlab-org/gitlab-ee
+ # - tags@gitlab-org/gitlab-ee \ No newline at end of file
diff --git a/lib/tasks/ci/slack.rake b/lib/tasks/ci/slack.rake
deleted file mode 100644
index 0afc0e908d1..00000000000
--- a/lib/tasks/ci/slack.rake
+++ /dev/null
@@ -1,9 +0,0 @@
-namespace :ci do
- namespace :slack do
- desc "GitLab CI | Send slack notification on build failure"
- 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
diff --git a/scripts/notify_slack.sh b/scripts/notify_slack.sh
new file mode 100755
index 00000000000..0a4239e132c
--- /dev/null
+++ b/scripts/notify_slack.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+# Sends Slack notification ERROR_MSG to CHANNEL
+# An env. variable CI_SLACK_WEBHOOK_URL needs to be set.
+
+CHANNEL=$1
+ERROR_MSG=$2
+
+if [ -z "$CHANNEL" ] || [ -z "$ERROR_MSG" ] || [ -z "$CI_SLACK_WEBHOOK_URL" ]; then
+ echo "Missing argument(s) - Use: $0 channel message"
+ echo "and set CI_SLACK_WEBHOOK_URL environment variable."
+else
+ curl -X POST --data-urlencode 'payload={"channel": "'"$CHANNEL"'", "username": "gitlab-ci", "text": "'"$ERROR_MSG"'", "icon_emoji": ":gitlab:"}' "$CI_SLACK_WEBHOOK_URL"
+fi \ No newline at end of file