diff --git a/rails/gitlab-ci.yml b/rails/gitlab-ci.yml
index 7c067ceb618567702cb9ff52dcce2763a78769c6..75b0ca18fed5a10a51acabd187904f45af845e17 100644
--- a/rails/gitlab-ci.yml
+++ b/rails/gitlab-ci.yml
@@ -1,9 +1,8 @@
-variables:
-  CI: "true"
-  RAILS_ENV: test
-
 set_ruby_version:
   stage: build
+  variables:
+    CI: "true"
+    RAILS_ENV: test
   script:
     - echo "RUBY_VERSION=$(cat .ruby-version | sed 's/ruby-//g')" >> build.env
   artifacts:
@@ -13,6 +12,9 @@ set_ruby_version:
 rubocop:
   stage: test
   image: ruby:$RUBY_VERSION
+  variables:
+    CI: "true"
+    RAILS_ENV: test
   tags:
     - rails
   script:
@@ -23,6 +25,9 @@ rubocop:
 erb_lint:
   stage: test
   image: ruby:$RUBY_VERSION
+  variables:
+    CI: "true"
+    RAILS_ENV: test
   tags:
     - rails
   script:
@@ -34,6 +39,9 @@ erb_lint:
 haml_lint:
   stage: test
   image: ruby:$RUBY_VERSION
+  variables:
+    CI: "true"
+    RAILS_ENV: test
   tags:
     - rails
   script:
@@ -44,6 +52,9 @@ haml_lint:
 brakeman:
   stage: test
   image: ruby:$RUBY_VERSION
+  variables:
+    CI: "true"
+    RAILS_ENV: test
   tags:
     - rails
   script:
@@ -52,13 +63,15 @@ brakeman:
     - brakeman -A --except UnscopedFind
 
 rails_test:
-  image: ruby:$RUBY_VERSION
   stage: test
+  image: ruby:$RUBY_VERSION
   tags:
     - rails
   services:
     - postgres:16.4
   variables:
+    CI: "true"
+    RAILS_ENV: test
     POSTGRES_DB: postgres
     POSTGRES_USER: postgres
     POSTGRES_PASSWORD: postgres