diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index e911d7e5b89a15b705d7741eaf8a2bd05fab74fa..ddc2c5f25423429711049119692f49f7db2a9f7e 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -19,8 +19,8 @@ variables:
 
 before_script:
   - bundle --version
-  - . scripts/utils.sh
-  - ./scripts/prepare_build.sh
+  - source scripts/utils.sh
+  - source scripts/prepare_build.sh
 
 stages:
 - prepare
diff --git a/config/initializers/rspec_profiling.rb b/config/initializers/rspec_profiling.rb
index b909cc5b9a4fb775cee5716b9983524ee2fb24cd..a7efd74f09e93d9afdb62f1604807e54d3611432 100644
--- a/config/initializers/rspec_profiling.rb
+++ b/config/initializers/rspec_profiling.rb
@@ -36,10 +36,10 @@ def example_finished(*args)
       RspecProfiling::Collectors::PSQL.prepend(RspecProfilingExt::PSQL)
       config.collector = RspecProfiling::Collectors::PSQL
     end
-  end
 
-  if ENV.has_key?('CI') && ENV['GITLAB_DATABASE'] == 'postgresql'
-    RspecProfiling::VCS::Git.prepend(RspecProfilingExt::Git)
-    RspecProfiling::Run.prepend(RspecProfilingExt::Run)
+    if ENV.key?('CI')
+      RspecProfiling::VCS::Git.prepend(RspecProfilingExt::Git)
+      RspecProfiling::Run.prepend(RspecProfilingExt::Run)
+    end
   end
 end
diff --git a/scripts/prepare_build.sh b/scripts/prepare_build.sh
old mode 100755
new mode 100644
index fd173c0ba88dce6bcfae83cd38eb0b3210ca69df..c727a0e2d884e2d7b574771277a011195fc4352c
--- a/scripts/prepare_build.sh
+++ b/scripts/prepare_build.sh
@@ -1,5 +1,3 @@
-#!/bin/sh
-
 . scripts/utils.sh
 
 export SETUP_DB=${SETUP_DB:-true}
@@ -32,7 +30,7 @@ sed -i 's/localhost/redis/g' config/resque.yml
 cp config/gitlab.yml.example config/gitlab.yml
 
 if [ "$USE_BUNDLE_INSTALL" != "false" ]; then
-    retry bundle install --clean $BUNDLE_INSTALL_FLAGS && bundle check
+    bundle install --clean $BUNDLE_INSTALL_FLAGS && bundle check
 fi
 
 # Only install knapsack after bundle install! Otherwise oddly some native
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index e67ad8f345593e9bd433cd475db6b9324d58884a..e2d5928e5b2420962dd101421bf17ce4a9d4356a 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -13,8 +13,9 @@
   ENV['RSPEC_PROFILING_POSTGRES_URL'] ||
   ENV['RSPEC_PROFILING']
 branch_can_be_profiled =
-  ENV['CI_COMMIT_REF_NAME'] == 'master' ||
-  ENV['CI_COMMIT_REF_NAME'] =~ /rspec-profile/
+  ENV['GITLAB_DATABASE'] == 'postgresql' &&
+  (ENV['CI_COMMIT_REF_NAME'] == 'master' ||
+    ENV['CI_COMMIT_REF_NAME'] =~ /rspec-profile/)
 
 if rspec_profiling_is_configured && (!ENV.key?('CI') || branch_can_be_profiled)
   require 'rspec_profiling/rspec'