kasm-workspaces-core-images/ci-scripts/download-trivy
Francis Ferrell ea3a4df0a0
QA-272 cache trivy in S3
This changes how the pipeline installs trivy. A scheduled job in the
qa-infrastructure project will download the latest release and store it
in S3. Jobs that use trivy retrieve it from there. This avoids rate
limiting and gives us more control over the version of trivy we use.
2026-03-25 10:23:01 -04:00

18 lines
598 B
Bash

#!/bin/bash
set -euo pipefail
arch=$(arch | sed -e 's/aarch64/arm64/g' -e 's/x86_64/x86/g')
download_dir=$( mktemp -td )
curl -fsSLO --output-dir "$download_dir" "https://${S3_BUCKET}.s3.amazonaws.com/trivy/trivy-${arch}.tar.gz"
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
trivy_dir="${SCRIPT_DIR}/trivy"
rm -rf $trivy_dir
mkdir $trivy_dir
cd $trivy_dir
tar -zxvf "${download_dir}/trivy-${arch}.tar.gz"
echo "Using trivy $( ./trivy --version )"
if [[ -e "${SCRIPT_DIR}/junit.tpl" ]]; then
cp -v "${SCRIPT_DIR}/junit.tpl" "${SCRIPT_DIR}/trivy/contrib/"
fi