Skip to content

Commit

Permalink
Refactor pull script
Browse files Browse the repository at this point in the history
  • Loading branch information
carminevassallo committed Oct 9, 2023
1 parent dbce63f commit 16dd63d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 87 deletions.
10 changes: 8 additions & 2 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,15 @@ private_scan_task:
- curl -sSL https://unified-agent.s3.amazonaws.com/wss-unified-agent.jar -o wss-unified-agent.jar
- echo "docker.includes=${tag}" >> .cirrus/wss-unified-agent.config
scan_script:
- .cirrus/private-scan-task.sh "${STAGING_IMAGE_NAME}" "${tag}" "${platform}" "${WS_PRODUCTNAME}" "${WS_WSS_URL}" "${MEND_API_KEY}"
- echo "Scan the ${STAGING_IMAGE_NAME}:${tag} image supporting linux/${platform}"
- .cirrus/pull.sh ${STAGING_IMAGE_NAME} ${tag} ${platform}
- java -jar wss-unified-agent.jar -c .cirrus/wss-unified-agent.config -apiKey $MEND_API_KEY -product ${WS_PRODUCTNAME} -project ${STAGING_IMAGE_NAME}:${tag} -wss.url ${WS_WSS_URL} -docker.scanImages true
depends_on: multi_arch_build

public_scan_task:
only_if: $CIRRUS_CRON == 'nightly-mend-scan'
env:
platform: amd64
MEND_API_KEY: VAULT[development/kv/data/mend data.apikey]
WS_WSS_URL: https://saas-eu.whitesourcesoftware.com/agent
matrix:
Expand All @@ -102,7 +105,10 @@ public_scan_task:
- curl -sSL https://unified-agent.s3.amazonaws.com/wss-unified-agent.jar -o wss-unified-agent.jar
- echo "docker.includes=${tag}" >> .cirrus/wss-unified-agent.config
scan_script:
- .cirrus/public-scan-task.sh "${PUBLIC_IMAGE_NAME}" "${tag}" "${WS_PRODUCTNAME}" "${WS_WSS_URL}" "${MEND_API_KEY}"
- echo "Scan the ${PUBLIC_IMAGE_NAME}:${tag} image"
- docker pull "${PUBLIC_IMAGE_NAME}:${tag}"
- .cirrus/pull.sh ${PUBLIC_IMAGE_NAME} ${tag} ${platform}
- java -jar wss-unified-agent.jar -c .cirrus/wss-unified-agent.config -apiKey $MEND_API_KEY -product ${WS_PRODUCTNAME} -project ${PUBLIC_IMAGE_NAME}:${tag} -wss.url ${WS_WSS_URL} -docker.scanImages true

multi_arch_test_task:
matrix:
Expand Down
43 changes: 0 additions & 43 deletions .cirrus/private-scan-task.sh

This file was deleted.

42 changes: 0 additions & 42 deletions .cirrus/public-scan-task.sh

This file was deleted.

15 changes: 15 additions & 0 deletions .cirrus/pull.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

IMAGE_NAME=${1}
tag=${2}
platform=${3}

for i in $(seq 1 3); do
if docker pull --platform linux/"${platform}" "${IMAGE_NAME}:${tag}"; then
exit 0
fi
echo "[${i}/3] Retrying to pull image ${IMAGE_NAME}:${tag}..."
sleep 5
done
echo "[Error]: Failed to pull image ${IMAGE_NAME}:${tag}"
exit 1

0 comments on commit 16dd63d

Please sign in to comment.