diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index c477721f9da67a1912242535d8fa9a6f5f71556c..f77b5bdc955d687fada6fd72a5899d949e69d43e 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -12,6 +12,8 @@ cache:
 
 variables:
   MYSQL_ALLOW_EMPTY_PASSWORD: "1"
+  # retry tests only in CI environment
+  RSPEC_RETRY_RETRY_COUNT: "3"
 
 before_script:
   - source ./scripts/prepare_build.sh
diff --git a/Gemfile b/Gemfile
index c66ef3cffada3d03b5aac83df8182e143304915f..a5c244fb7b688db86521985ac5c7db0aa1193a17 100644
--- a/Gemfile
+++ b/Gemfile
@@ -263,6 +263,7 @@ group :development, :test do
   gem 'database_cleaner',   '~> 1.4.0'
   gem 'factory_girl_rails', '~> 4.6.0'
   gem 'rspec-rails',        '~> 3.3.0'
+  gem 'rspec-retry'
   gem 'spinach-rails',      '~> 0.2.1'
 
   # Prevent occasions where minitest is not bundled in packaged versions of ruby (see #3826)
diff --git a/Gemfile.lock b/Gemfile.lock
index 22c86e4ae8fc480fd20a2ad3f93cc01aeb64bc63..7f3c5911e5f1d04d3da01a6f8f62f62f09639689 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -679,6 +679,8 @@ GEM
       rspec-expectations (~> 3.3.0)
       rspec-mocks (~> 3.3.0)
       rspec-support (~> 3.3.0)
+    rspec-retry (0.4.5)
+      rspec-core
     rspec-support (3.3.0)
     rubocop (0.35.1)
       astrolabe (~> 1.3)
@@ -999,6 +1001,7 @@ DEPENDENCIES
   rouge (~> 1.10.1)
   rqrcode-rails3 (~> 0.1.7)
   rspec-rails (~> 3.3.0)
+  rspec-retry
   rubocop (~> 0.35.0)
   ruby-fogbugz (~> 0.2.1)
   sanitize (~> 2.0)
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 8f381f46e5774c269466e1603b02f9f63ff99ece..159fb964171865065b8fd3d40d68e0f8d4c71cbf 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -15,6 +15,7 @@ require 'rspec/rails'
 require 'shoulda/matchers'
 require 'sidekiq/testing/inline'
 require 'benchmark/ips'
+require 'rspec/retry'
 
 # Requires supporting ruby files with custom matchers and macros, etc,
 # in spec/support/ and its subdirectories.
@@ -25,6 +26,9 @@ RSpec.configure do |config|
   config.use_instantiated_fixtures  = false
   config.mock_with :rspec
 
+  config.verbose_retry = true
+  config.display_try_failure_messages = true
+
   config.include Devise::TestHelpers, type: :controller
   config.include LoginHelpers,        type: :feature
   config.include LoginHelpers,        type: :request