diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 4d264cff88141411f5671beef8efb8cb26feed06..bae1c2fe73f0a38a6aac55d5cef6a4cd37ff3986 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -121,15 +121,16 @@ VM Heartbeat:
     - |
       for i in {1..18}; do
         sleep 10
-        response=$(curl --silent --write-out "%{http_code}\n" --output /dev/null --connect-timeout 5 --max-time 10 http://10.212.26.72/server/heartbeat)
-        echo "Response: $response"
-        if [ "$response" -eq 200 ]; then
-          echo "Server is alive"
+        response_code=$(curl --silent --write-out "%{http_code}\n" --output response.txt --connect-timeout 5 --max-time 10 http://10.212.26.72/server/heartbeat)
+        response_body=$(cat response.txt)
+        echo "Response code: $response_code"
+        echo "Response body: $response_body"
+        if [ "$response_code" -eq 200 ]; then
           exit 0
         fi
       done
       echo "Server did not respond with 200 OK after 3 minutes"
       exit 1
-  only:
-    refs:
-      - main
\ No newline at end of file
+  rules:
+    - if: '$CI_COMMIT_BRANCH == "main"'
+    - if: '$CI_PIPELINE_SOURCE == "schedule" && $RUN_VM_HEARTBEAT == "true"'
\ No newline at end of file