Skip to content

Commit

Permalink
SONAR-20590 Add retry mechanism for public and private scan tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
davividal authored Oct 10, 2023
1 parent bbc5a01 commit 0cd256f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,14 @@ private_scan_task:
- echo "docker.includes=${tag}" >> .cirrus/wss-unified-agent.config
scan_script:
- echo "Scan the ${STAGING_IMAGE_NAME}:${tag} image supporting linux/${platform}"
- docker pull --platform linux/${platform} "${STAGING_IMAGE_NAME}:${tag}"
- .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 @@ -106,6 +107,7 @@ public_scan_task:
scan_script:
- 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:
Expand Down
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 0cd256f

Please sign in to comment.