diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index fbb2494ac0d2a33440a076a850ebdab4e4ef07d1..31799d8f1cd0d6d6563b137a1ad79615747457cd 100755
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -12,8 +12,11 @@ variables:
     - changes: 
       - $IMAGE_NAME/Dockerfile
       - basis/*
+  needs:  # if the build_and_push step basis has to be done, then make the other build_and_push steps dependend of it
+    - job: basis
+      optional: true # only run if basis is added to the pipeline (depends on the rules).
   before_script:
-    - docker login -u $DOCKER_HUB_USER -p $DOCKER_TOKEN
+    - docker login -u "$DOCKER_HUB_USER" -p $DOCKER_TOKEN
   script:
       - docker build -t "$DOCKER_HUB_USER/etp_$IMAGE_NAME" $IMAGE_NAME/Dockerfile --no-cache;
       - docker push "$DOCKER_HUB_USER/etp_$IMAGE_NAME";
@@ -54,7 +57,7 @@ create_jupytermachine_version:
   script:
     - |
       IMAGES=( "basis" "tp" "python311") # "tp_herwig") #  "tp_geant" "cuda_basis"
-      docker login -u $DOCKER_HUB_USER -p $DOCKER_TOKEN
+      docker login -u "$DOCKER_HUB_USER" -p $DOCKER_TOKEN
       cd basis_jupytermachine
       for image in "${IMAGES[@]}"; do
 
@@ -62,7 +65,7 @@ create_jupytermachine_version:
         OLD_BASE_IMAGE=$(grep -E '^\s*FROM\s+.*' Dockerfile | awk '{print $2}');
         echo $OLD_BASE_IMAGE;
         # Replace "basic_jupytermachine" with the new base image name
-        NEW_BASE_IMAGE=$DOCKER_HUB_USER/etp_$image;
+        NEW_BASE_IMAGE="$DOCKER_HUB_USER/etp_$image";
         echo $NEW_BASE_IMAGE;
         sed -i "s#$OLD_BASE_IMAGE#$NEW_BASE_IMAGE#" "Dockerfile"
         cat Dockerfile;