engine: Enable deployment and testing for release jobs
[infra/cicd.git] / jjb / engine / scripts / download-artifact.sh
index 2cd405efcc1f0e6edbf23c3e96122d201d2cf5e2..3c559baeeb2dad972c081ffd36ae5d33789f7bb3 100755 (executable)
 
 set -o nounset
 set -o errexit
-set -o pipefail
 
 if [[ "$EXECUTION_MODE" == "offline-deployment" ]]; then
+  # ensure we delete leftovers due to lack of disk space
+  sudo /bin/rm -rf /tmp/$ARTIFACT_TO_DOWNLOAD \
+      /opt/engine /opt/test /opt/stack /httpboot || true
+  sudo docker ps -a | grep -v CONTAINER | awk '{print $1}' | xargs -n 1 sudo docker stop || true
+  sudo docker ps -a | grep -v CONTAINER | awk '{print $1}' | xargs -n 1 sudo docker rm || true
+  sudo docker images -a | grep -v CONTAINER | awk '{print $1":"$2}' | \
+      xargs -n 1 sudo docker rmi -f || true
+
+  # offline nodes can't resolve artifactory.nordix.org
   echo "Info  : Offline deployment. Adding Nordix ARM Public IP to /etc/hosts"
   sudo bash -c "cat << EOF >> /etc/hosts
 # managed by engine
 $NORDIX_ARM_PUBLIC_IP artifactory.nordix.org
 # managed by engine
 EOF"
-  echo "Info  : Downloading artifact from Nordix ARM."
+  echo "Info  : Downloading artifact from Nordix ARM..."
+  echo "        $NORDIX_ARTIFACT_URL/$ARTIFACT_TO_DOWNLOAD"
   cd /tmp
-  curl -s -O $NORDIX_ARTIFACT_URL
-  echo "Info  : Downloaded the artifact for offline deployment. Extracting."
-  chmod +x $ARTIFACT_TO_DOWNLOAD
-  $ARTIFACT_TO_DOWNLOAD
+  curl -s -O $NORDIX_ARTIFACT_URL/$ARTIFACT_TO_DOWNLOAD
+  echo "Info  : Downloaded the artifact for offline deployment. Extracting..."
+  echo "        $(ls -al /tmp/$ARTIFACT_TO_DOWNLOAD)"
+  chmod +x /tmp/$ARTIFACT_TO_DOWNLOAD
+  /tmp/$ARTIFACT_TO_DOWNLOAD
+  sudo /bin/rm -rf /tmp/$ARTIFACT_TO_DOWNLOAD
 else
   echo "Info  : Online deployment. Skipping artifact download."
 fi