diff options
author | James Lopez <james@jameslopez.es> | 2016-02-03 14:37:17 +0100 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2016-02-03 14:37:17 +0100 |
commit | 059d82637b5ab046c727df9a8150a6903ef32681 (patch) | |
tree | 31de944a1352d74d54914ef38b4d5b53731ab606 | |
parent | 494028445b2d63fbcb62b1ddc8260574e374505c (diff) | |
download | gitlab-ce-059d82637b5ab046c727df9a8150a6903ef32681.tar.gz |
update ci configuration to send slack notifications on failure and added rake task
-rw-r--r-- | .gitlab-ci.yml | 33 | ||||
-rw-r--r-- | lib/tasks/ci/slack.rake | 9 |
2 files changed, 41 insertions, 1 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index dbdbae9d787..4397c5add5a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -19,7 +19,12 @@ before_script: - bundle install --without postgres production --jobs $(nproc) "${FLAGS[@]}" - RAILS_ENV=test bundle exec rake db:drop db:create db:schema:load db:migrate +stages: +- test +- notifications + spec:feature: + stage: test script: - RAILS_ENV=test bundle exec rake assets:precompile 2>/dev/null - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:feature @@ -28,6 +33,7 @@ spec:feature: - mysql spec:api: + stage: test script: - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:api tags: @@ -35,6 +41,7 @@ spec:api: - mysql spec:models: + stage: test script: - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:models tags: @@ -42,6 +49,7 @@ spec:models: - mysql spec:lib: + stage: test script: - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:lib tags: @@ -49,6 +57,7 @@ spec:lib: - mysql spec:services: + stage: test script: - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:services tags: @@ -56,6 +65,7 @@ spec:services: - mysql spec:benchmark: + stage: test script: - RAILS_ENV=test bundle exec rake spec:benchmark tags: @@ -64,6 +74,7 @@ spec:benchmark: allow_failure: true spec:other: + stage: test script: - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:other tags: @@ -71,6 +82,7 @@ spec:other: - mysql spinach:project:half: + stage: test script: - RAILS_ENV=test SIMPLECOV=true bundle exec rake spinach:project:half tags: @@ -78,6 +90,7 @@ spinach:project:half: - mysql spinach:project:rest: + stage: test script: - RAILS_ENV=test SIMPLECOV=true bundle exec rake spinach:project:rest tags: @@ -85,6 +98,7 @@ spinach:project:rest: - mysql spinach:other: + stage: test script: - RAILS_ENV=test SIMPLECOV=true bundle exec rake spinach:other tags: @@ -92,6 +106,7 @@ spinach:other: - mysql teaspoon: + stage: test script: - RAILS_ENV=test bundle exec teaspoon tags: @@ -99,6 +114,7 @@ teaspoon: - mysql rubocop: + stage: test script: - bundle exec rubocop tags: @@ -106,6 +122,7 @@ rubocop: - mysql brakeman: + stage: test script: - bundle exec rake brakeman tags: @@ -113,6 +130,7 @@ brakeman: - mysql flog: + stage: test script: - bundle exec rake flog tags: @@ -120,6 +138,7 @@ flog: - mysql flay: + stage: test script: - bundle exec rake flay tags: @@ -127,6 +146,7 @@ flay: - mysql bundler:audit: + stage: test script: - "bundle exec bundle-audit update" - "bundle exec bundle-audit check" @@ -135,9 +155,10 @@ bundler:audit: - mysql allow_failure: true -# Ruby 2.1 jobs +## Ruby 2.1 jobs spec:ruby21: + stage: test image: ruby:2.1 script: - RAILS_ENV=test bundle exec rake assets:precompile 2>/dev/null @@ -149,6 +170,7 @@ spec:ruby21: - master spinach:ruby21: + stage: test image: ruby:2.1 script: - RAILS_ENV=test SIMPLECOV=true bundle exec rake spinach @@ -157,3 +179,12 @@ spinach:ruby21: - mysql only: - master + +notify:slack: + stage: notifications + script: + - bundle exec rake ci:slack + when: on_failure +# only: +# - master +# - tags
\ No newline at end of file diff --git a/lib/tasks/ci/slack.rake b/lib/tasks/ci/slack.rake new file mode 100644 index 00000000000..c4edda466ac --- /dev/null +++ b/lib/tasks/ci/slack.rake @@ -0,0 +1,9 @@ +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" + end + end +end |