由于政策原因,Gitlab 缓存未上传
Gitlab cache not uploading due to policy
我在我的 gitlab runner 中收到错误 Not uploading cache {name of branch} due to policy
。我的 .yaml
文件如下所示:
stages:
- test
- staging
- publish
- deploy
# cache using branch name
# https://gitlab.com/help/ci/caching/index.md
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- .yarn
- node_modules/
policy: pull
before_script:
- yarn install --cache-folder .yarn
test:
stage: test
image: node:14
script:
- yarn install
- yarn test
pages:
stage: staging
image: alekzonder/puppeteer
except:
- master
script:
- yarn install
- yarn compile
- yarn build
publish:
stage: publish
image: alekzonder/puppeteer
when: manual
script:
- yarn install
- yarn compile
- yarn build
artifacts:
paths:
- dist
deploy:
image: google/cloud-sdk:latest
stage: deploy
needs:
- publish
script:
- gcloud auth activate-service-account --account ${GCP_SERVICE_ACCOUNT} --key-file ${GOOGLE_APPLICATION_CREDENTIALS}
- gsutil -u test rsync -r -d dist/ gs://test.ca
我想知道为什么总是上传失败,从而无法提取缓存。欢迎任何提示或更正。这是它失败的地方的截图:
您有以下设置:
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- .yarn
- node_modules/
policy: pull
这开创了您只想 (policy: pull
) 从缓存中提取的管道全局先例。
你会想要阅读 https://docs.gitlab.com/ee/ci/yaml/#cachepolicy
如果省略 policy:
部分,则默认为 pull-push
(这将使您的缓存上传)。
不过,我的管道结构倾向于与您的略有不同。我通常有一个我定义的“准备”步骤,然后 运行 yarn install
在那里:
"Installing Dependencies":
image: node:lts
stage: Prep
cache:
paths:
- .yarn
- node_modules/
policy: pull-push
script:
yarn install
...
注意:然后您可以保留 'pull' 的全局策略,因为这一项工作将覆盖 pull-push。
然后,您可以删除所有其他任务的 yarn install
,因为缓存将被恢复。
我在我的 gitlab runner 中收到错误 Not uploading cache {name of branch} due to policy
。我的 .yaml
文件如下所示:
stages:
- test
- staging
- publish
- deploy
# cache using branch name
# https://gitlab.com/help/ci/caching/index.md
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- .yarn
- node_modules/
policy: pull
before_script:
- yarn install --cache-folder .yarn
test:
stage: test
image: node:14
script:
- yarn install
- yarn test
pages:
stage: staging
image: alekzonder/puppeteer
except:
- master
script:
- yarn install
- yarn compile
- yarn build
publish:
stage: publish
image: alekzonder/puppeteer
when: manual
script:
- yarn install
- yarn compile
- yarn build
artifacts:
paths:
- dist
deploy:
image: google/cloud-sdk:latest
stage: deploy
needs:
- publish
script:
- gcloud auth activate-service-account --account ${GCP_SERVICE_ACCOUNT} --key-file ${GOOGLE_APPLICATION_CREDENTIALS}
- gsutil -u test rsync -r -d dist/ gs://test.ca
我想知道为什么总是上传失败,从而无法提取缓存。欢迎任何提示或更正。这是它失败的地方的截图:
您有以下设置:
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- .yarn
- node_modules/
policy: pull
这开创了您只想 (policy: pull
) 从缓存中提取的管道全局先例。
你会想要阅读 https://docs.gitlab.com/ee/ci/yaml/#cachepolicy
如果省略 policy:
部分,则默认为 pull-push
(这将使您的缓存上传)。
不过,我的管道结构倾向于与您的略有不同。我通常有一个我定义的“准备”步骤,然后 运行 yarn install
在那里:
"Installing Dependencies":
image: node:lts
stage: Prep
cache:
paths:
- .yarn
- node_modules/
policy: pull-push
script:
yarn install
...
注意:然后您可以保留 'pull' 的全局策略,因为这一项工作将覆盖 pull-push。
然后,您可以删除所有其他任务的 yarn install
,因为缓存将被恢复。