diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 625385ca30da7d5dd88db4d1607794043cbc94f8..f7a7c22a388dee7a41a34cb0466dbecdcacd6fcd 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -55,14 +55,21 @@ test:
 deploy-to-staging:
   stage: deploy
   script:
+    # Authentication setup
     - mkdir -p ~/.ssh
     - echo "$SSH_PRIVATE_KEY" >> ~/.ssh/id_dsa
     - chmod 600 ~/.ssh/id_dsa
     - echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
+    # Find name of war file in target folder (built previously in build stage), exit if none exists
     - WAR_FILE=$(find target -maxdepth 1 -type f -name "*.war" | sort -n | tail -1 | xargs basename)
     - if [ -z "$WAR_FILE" ]; then echo "No war file found in target directory"; exit 1; fi
+    # Create temporary directory on server, copy war file and deployment script there
     - echo "Create temporary directory on the server"
     - ssh $SERVER_USER@$SERVER_IP "mkdir -p $TMP_PATH"
+    - scp target/$WAR_FILE $SERVER_USER@$SERVER_IP:$TMP_PATH
+    - echo "deploy $TMP_PATH/$WAR_FILE --force" > deploy.cli
+    - scp deploy.cli $SERVER_USER@$SERVER_IP:$TMP_PATH
+    # Find version of currently deployed appliation, archive timestamped war file. Skip if no deployed war file is found.
     - echo "Archive currently deployed application"
     - CURRENT_VERSION=$(ssh $SERVER_USER@$SERVER_IP "ls $DEPLOYMENT_PATH/VIPSCore-*.war | head -n 1 | sed -n 's/.*VIPSCore-\(.*\)\.war/\1/p'")
     - |
@@ -70,17 +77,19 @@ deploy-to-staging:
         TIMESTAMP=$(date +'%Y%m%d%H%M%S')
         ssh $SERVER_USER@$SERVER_IP "mv $DEPLOYMENT_PATH/VIPSCore-${CURRENT_VERSION}.war $ARCHIVE_PATH/VIPSCore-${CURRENT_VERSION}-${TIMESTAMP}.war"
       else
-        echo "No matching file found. Skipping archive step."
+        echo "No matching war file found. Skip archive step."
       fi
+    # Deploy war file using JBoss CLI and credentials given in CI/CD variables
     - echo "Deploy $WAR_FILE using JBoss CLI"
-    - scp target/$WAR_FILE $SERVER_USER@$SERVER_IP:$TMP_PATH
-    - echo "deploy $TMP_PATH/$WAR_FILE --force" > deploy.cli
-    - scp deploy.cli $SERVER_USER@$SERVER_IP:$TMP_PATH
     - ssh $SERVER_USER@$SERVER_IP "/disks/data01/wildfly/wildfly-25.0.1.Final/bin/jboss-cli.sh --user=$WILDFLY_ADMIN_USERNAME --password=$WILDFLY_ADMIN_PASSWORD --connect --file=$TMP_PATH/deploy.cli"
+    # Restart should not be necessary
     - echo "Restart WildFly"
     - ssh $SERVER_USER@$SERVER_IP "sudo systemctl restart wildfly"
+    # Delete temporary directory on server
     - echo "Delete temporary directory"
     - ssh $SERVER_USER@$SERVER_IP "rm -rf $TMP_PATH"
+  after_script:
+    - echo "Deployment complete"
   tags:
     - vips-java
   rules: