Skip to content

Commit 4db91c6

Browse files
authored
Fix Gitlab cache issues (#3160)
* Make parent cache download quiet This spammed logs quite a bit * Add "-p" to "mkdir $CI_PROJECT_DIR/cache-artifact" Otherwise the after_script is silently aborted when the dir already exists. * Extract parent cache artifact in own directory and later delete it Otherwise we end up having "testlogs" (and maybe other stuff) in the project directory, which causes future failures.
1 parent e9ed354 commit 4db91c6

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

.gitlab-ci.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,17 @@ stages:
3333
if [ "$CI_COMMIT_REF_SLUG" != "develop" -a "$CI_COMMIT_TAG" == "" ]; then
3434
if [ ! -d $CACHE_DIR/ccache ]; then
3535
echo "Downloading cache from develop branch"
36-
if wget -O cache-artifact.zip https://gitlab.com/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME/-/jobs/artifacts/develop/download?job=$CI_JOB_NAME; then
37-
unzip cache-artifact.zip
36+
mkdir cache-artifact
37+
cd cache-artifact
38+
if wget --quiet -O cache-artifact.zip https://gitlab.com/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME/-/jobs/artifacts/develop/download?job=$CI_JOB_NAME; then
39+
unzip -q cache-artifact.zip
3840
rm cache-artifact.zip
3941
mv cache-artifact/* $CACHE_DIR/
4042
else
4143
echo "Failed to download cache"
4244
fi
45+
cd ..
46+
rm -rf cache-artifact
4347
else
4448
echo "Not touching cache (was initialized from previous build)"
4549
fi
@@ -97,7 +101,7 @@ stages:
97101
after_script:
98102
# Copy all cache files into cache-artifact so that they get uploaded. We only do this for develop so that artifacts
99103
# stay minimal for PRs and branches (we never need them)
100-
- mkdir $CI_PROJECT_DIR/cache-artifact
104+
- mkdir -p $CI_PROJECT_DIR/cache-artifact
101105
- mkdir -p $CI_PROJECT_DIR/testlogs
102106
- |
103107
if [ "$CI_COMMIT_REF_SLUG" = "develop" ]; then

0 commit comments

Comments
 (0)