File tree Expand file tree Collapse file tree
tests/integration/codebuild-local Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,6 +17,22 @@ function usage {
1717 >&2 echo " env Additional environment variables file."
1818}
1919
20+ function pull_with_retry() {
21+ local image=" $1 "
22+ local max_retries=3
23+ local wait=10
24+ for attempt in $( seq 1 $max_retries ) ; do
25+ if docker pull " $image " ; then
26+ return 0
27+ fi
28+ >&2 echo " Docker pull attempt $attempt /$max_retries failed. Retrying in ${wait} s..."
29+ sleep $wait
30+ wait=$(( wait * 2 ))
31+ done
32+ >&2 echo " Failed to pull $image after $max_retries attempts."
33+ return 1
34+ }
35+
2036main () {
2137 if (( $# != 3 && $# != 4 )) ; then
2238 >&2 echo " Invalid number of parameters."
@@ -49,6 +65,9 @@ main() {
4965 ARTIFACTS_DIR=" $CODEBUILD_TEMP_DIR /artifacts"
5066 mkdir -p " $ARTIFACTS_DIR "
5167
68+ # Pre-pull the CodeBuild local agent image with retries to handle ECR rate limits.
69+ pull_with_retry " public.ecr.aws/codebuild/local-builds:latest"
70+
5271 # Run CodeBuild local agent.
5372 " $( dirname " $0 " ) " /codebuild_build.sh \
5473 -i " $CODEBUILD_IMAGE_TAG " \
You can’t perform that action at this time.
0 commit comments