diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 184e6f9017c54b7f5ac287f87b8a6fcbe42a38bc..23d261d459aa734665e153e0a45639ac31f0f993 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -4,8 +4,6 @@
       GIT_SUBMODULE_STRATEGY: recursive
   
   before_script:
-      - git submodule sync --recursive
-      - git submodule update --init --recursive
       - which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )
       - eval $(ssh-agent -s)
       - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
@@ -14,6 +12,8 @@
       - ssh-keyscan -p 2202 gitlab.iri.upc.edu  >> ~/.ssh/known_hosts
       - chmod 644 ~/.ssh/known_hosts
       - ssh -p 2202 git@gitlab.iri.upc.edu #test
+      - git submodule sync --recursive
+      - git submodule update --init --recursive
 
   stages:
     - build