Commit 4a9affa7 authored by James Lopez's avatar James Lopez

Merge branch 'feature/slack-notifications-on-ci' into 'master'

update ci configuration to send slack notifications on failure

Updates CI config file and adds a task to send notifications when a build fails on master or on any tag.

Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/12805

See merge request !2681
parents fc31840d 86b97ce1
...@@ -24,7 +24,12 @@ before_script: ...@@ -24,7 +24,12 @@ before_script:
- bundle install --without postgres production --jobs $(nproc) "${FLAGS[@]}" - bundle install --without postgres production --jobs $(nproc) "${FLAGS[@]}"
- RAILS_ENV=test bundle exec rake db:drop db:create db:schema:load db:migrate - RAILS_ENV=test bundle exec rake db:drop db:create db:schema:load db:migrate
stages:
- test
- notifications
spec:feature: spec:feature:
stage: test
script: script:
- RAILS_ENV=test bundle exec rake assets:precompile 2>/dev/null - RAILS_ENV=test bundle exec rake assets:precompile 2>/dev/null
- RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:feature - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:feature
...@@ -33,6 +38,7 @@ spec:feature: ...@@ -33,6 +38,7 @@ spec:feature:
- mysql - mysql
spec:api: spec:api:
stage: test
script: script:
- RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:api - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:api
tags: tags:
...@@ -40,6 +46,7 @@ spec:api: ...@@ -40,6 +46,7 @@ spec:api:
- mysql - mysql
spec:models: spec:models:
stage: test
script: script:
- RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:models - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:models
tags: tags:
...@@ -47,6 +54,7 @@ spec:models: ...@@ -47,6 +54,7 @@ spec:models:
- mysql - mysql
spec:lib: spec:lib:
stage: test
script: script:
- RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:lib - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:lib
tags: tags:
...@@ -54,6 +62,7 @@ spec:lib: ...@@ -54,6 +62,7 @@ spec:lib:
- mysql - mysql
spec:services: spec:services:
stage: test
script: script:
- RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:services - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:services
tags: tags:
...@@ -61,6 +70,7 @@ spec:services: ...@@ -61,6 +70,7 @@ spec:services:
- mysql - mysql
spec:benchmark: spec:benchmark:
stage: test
script: script:
- RAILS_ENV=test bundle exec rake spec:benchmark - RAILS_ENV=test bundle exec rake spec:benchmark
tags: tags:
...@@ -69,6 +79,7 @@ spec:benchmark: ...@@ -69,6 +79,7 @@ spec:benchmark:
allow_failure: true allow_failure: true
spec:other: spec:other:
stage: test
script: script:
- RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:other - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:other
tags: tags:
...@@ -76,6 +87,7 @@ spec:other: ...@@ -76,6 +87,7 @@ spec:other:
- mysql - mysql
spinach:project:half: spinach:project:half:
stage: test
script: script:
- RAILS_ENV=test SIMPLECOV=true bundle exec rake spinach:project:half - RAILS_ENV=test SIMPLECOV=true bundle exec rake spinach:project:half
tags: tags:
...@@ -83,6 +95,7 @@ spinach:project:half: ...@@ -83,6 +95,7 @@ spinach:project:half:
- mysql - mysql
spinach:project:rest: spinach:project:rest:
stage: test
script: script:
- RAILS_ENV=test SIMPLECOV=true bundle exec rake spinach:project:rest - RAILS_ENV=test SIMPLECOV=true bundle exec rake spinach:project:rest
tags: tags:
...@@ -90,6 +103,7 @@ spinach:project:rest: ...@@ -90,6 +103,7 @@ spinach:project:rest:
- mysql - mysql
spinach:other: spinach:other:
stage: test
script: script:
- RAILS_ENV=test SIMPLECOV=true bundle exec rake spinach:other - RAILS_ENV=test SIMPLECOV=true bundle exec rake spinach:other
tags: tags:
...@@ -97,6 +111,7 @@ spinach:other: ...@@ -97,6 +111,7 @@ spinach:other:
- mysql - mysql
teaspoon: teaspoon:
stage: test
script: script:
- RAILS_ENV=test bundle exec teaspoon - RAILS_ENV=test bundle exec teaspoon
tags: tags:
...@@ -104,6 +119,7 @@ teaspoon: ...@@ -104,6 +119,7 @@ teaspoon:
- mysql - mysql
rubocop: rubocop:
stage: test
script: script:
- bundle exec rubocop - bundle exec rubocop
tags: tags:
...@@ -111,6 +127,7 @@ rubocop: ...@@ -111,6 +127,7 @@ rubocop:
- mysql - mysql
brakeman: brakeman:
stage: test
script: script:
- bundle exec rake brakeman - bundle exec rake brakeman
tags: tags:
...@@ -118,6 +135,7 @@ brakeman: ...@@ -118,6 +135,7 @@ brakeman:
- mysql - mysql
flog: flog:
stage: test
script: script:
- bundle exec rake flog - bundle exec rake flog
tags: tags:
...@@ -125,6 +143,7 @@ flog: ...@@ -125,6 +143,7 @@ flog:
- mysql - mysql
flay: flay:
stage: test
script: script:
- bundle exec rake flay - bundle exec rake flay
tags: tags:
...@@ -132,6 +151,7 @@ flay: ...@@ -132,6 +151,7 @@ flay:
- mysql - mysql
bundler:audit: bundler:audit:
stage: test
script: script:
- "bundle exec bundle-audit update" - "bundle exec bundle-audit update"
- "bundle exec bundle-audit check" - "bundle exec bundle-audit check"
...@@ -143,6 +163,7 @@ bundler:audit: ...@@ -143,6 +163,7 @@ bundler:audit:
# Ruby 2.2 jobs # Ruby 2.2 jobs
spec:feature:ruby22: spec:feature:ruby22:
stage: test
image: ruby:2.2 image: ruby:2.2
only: only:
- master - master
...@@ -158,6 +179,7 @@ spec:feature:ruby22: ...@@ -158,6 +179,7 @@ spec:feature:ruby22:
- mysql - mysql
spec:api:ruby22: spec:api:ruby22:
stage: test
image: ruby:2.2 image: ruby:2.2
only: only:
- master - master
...@@ -172,6 +194,7 @@ spec:api:ruby22: ...@@ -172,6 +194,7 @@ spec:api:ruby22:
- mysql - mysql
spec:models:ruby22: spec:models:ruby22:
stage: test
image: ruby:2.2 image: ruby:2.2
only: only:
- master - master
...@@ -186,6 +209,7 @@ spec:models:ruby22: ...@@ -186,6 +209,7 @@ spec:models:ruby22:
- mysql - mysql
spec:lib:ruby22: spec:lib:ruby22:
stage: test
image: ruby:2.2 image: ruby:2.2
only: only:
- master - master
...@@ -200,6 +224,7 @@ spec:lib:ruby22: ...@@ -200,6 +224,7 @@ spec:lib:ruby22:
- mysql - mysql
spec:services:ruby22: spec:services:ruby22:
stage: test
image: ruby:2.2 image: ruby:2.2
only: only:
- master - master
...@@ -214,6 +239,7 @@ spec:services:ruby22: ...@@ -214,6 +239,7 @@ spec:services:ruby22:
- mysql - mysql
spec:benchmark:ruby22: spec:benchmark:ruby22:
stage: test
image: ruby:2.2 image: ruby:2.2
only: only:
- master - master
...@@ -229,6 +255,7 @@ spec:benchmark:ruby22: ...@@ -229,6 +255,7 @@ spec:benchmark:ruby22:
allow_failure: true allow_failure: true
spec:other:ruby22: spec:other:ruby22:
stage: test
image: ruby:2.2 image: ruby:2.2
only: only:
- master - master
...@@ -243,6 +270,7 @@ spec:other:ruby22: ...@@ -243,6 +270,7 @@ spec:other:ruby22:
- mysql - mysql
spinach:project:half:ruby22: spinach:project:half:ruby22:
stage: test
image: ruby:2.2 image: ruby:2.2
only: only:
- master - master
...@@ -257,6 +285,7 @@ spinach:project:half:ruby22: ...@@ -257,6 +285,7 @@ spinach:project:half:ruby22:
- mysql - mysql
spinach:project:rest:ruby22: spinach:project:rest:ruby22:
stage: test
image: ruby:2.2 image: ruby:2.2
only: only:
- master - master
...@@ -271,6 +300,7 @@ spinach:project:rest:ruby22: ...@@ -271,6 +300,7 @@ spinach:project:rest:ruby22:
- mysql - mysql
spinach:other:ruby22: spinach:other:ruby22:
stage: test
image: ruby:2.2 image: ruby:2.2
only: only:
- master - master
...@@ -284,3 +314,14 @@ spinach:other:ruby22: ...@@ -284,3 +314,14 @@ spinach:other:ruby22:
- ruby - ruby
- mysql - mysql
notify:slack:
stage: notifications
script:
- ./scripts/notify_slack.sh "#builds" "Build failed for master/tags!"
when: on_failure
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
#!/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
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