From 6cdafa58cb62ee53af69c118bd53f789bf5fc4b7 Mon Sep 17 00:00:00 2001
From: Marco Emilio Poleggi <marco-emilio.poleggi@hesge.ch>
Date: Wed, 16 Aug 2023 11:13:06 +0200
Subject: [PATCH] CI/CD Pipeline: move before_script inside a default block

---
 .gitlab-ci.yml | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 8e07380..9071d53 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -11,19 +11,20 @@ stages:
   - test
   - deploy
 
-# Commmon to all stages -- needed because the image's storage is not persistent across them
-before_script:
-  # uncomment for debugging. Watch out! It *will* expose any secret passed from an unprotected variable.
-  # - export
-  - apk -U add git openssh-client rsync
-  - mkdir -p -m 0700 ~/.ssh
-  - touch ~/.ssh/known_hosts && chmod 644 ~/.ssh/known_hosts
-  - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" >> ~/.ssh/config'
-  - git config --global user.email "deployer@ci-cd.lab"
-  - git config --global user.name "The Deployer"
-  - eval $(ssh-agent -s)
-  - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
-  - echo "$SSH_KNOWN_HOSTS" >> ~/.ssh/known_hosts
+default:
+  # Commmon to all stages -- needed because the image's storage is not persistent across them
+  before_script:
+    # uncomment for debugging. Watch out! It *will* expose any secret passed from an unprotected variable.
+    # - export
+    - apk -U add git openssh-client rsync
+    - mkdir -p -m 0700 ~/.ssh
+    - touch ~/.ssh/known_hosts && chmod 644 ~/.ssh/known_hosts
+    - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" >> ~/.ssh/config'
+    - git config --global user.email "deployer@ci-cd.lab"
+    - git config --global user.name "The Deployer"
+    - eval $(ssh-agent -s)
+    - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
+    - echo "$SSH_KNOWN_HOSTS" >> ~/.ssh/known_hosts
 
 unit_test1:
   stage: test
-- 
GitLab