CI cache can overwrite artifacts meant to be deployed
We had this problem in this pipeline: https://gitlab.com/gitlab-com/www-gitlab-com/pipelines/5571648
We were trying to deploying a blog post but the blog index was an old file. Even though the artifacts.zip for that pipeline contained the correct, updated index.html file.
Looking at the build log we saw that artifacts get unpacked first and then the cache is restored. We fixed the problem by adding a cache: {}
line to the deploy section.
Full broken gitlab-ci.yml: https://gitlab.com/gitlab-com/www-gitlab-com/blob/4178f0dd384298d494c932d3edfa2b86cfef3d36/.gitlab-ci.yml
Cache section:
cache:
key: "website"
paths:
- public
- vendor
Artifacts:
.build_base: &build_base
stage: build
artifacts:
expire_in: 7 days
paths:
- public/
tags:
- kubernetes
- gitlab-org
Note that the public
directory is both cached and part of the artifacts.
I think we either need to change the behavior when this happens (unpack artifacts after cache?) or protect users from this gotcha (detect path overlap?).