首页 > 解决方案 > 启用缓存时 GitLab CI/CD jekyll 构建失败

问题描述

我正在使用 GitLab CI/CD 管道来构建和部署一个 jekyll 网站。当我没有激活缓存时,以下设置有效。

image: ruby:2.6

# Cache gems in between builds
cache:
  key: ${CI_COMMIT_REF_SLUG}
  paths:
    - vendor/ruby

before_script:
  - gem install bundler
  #- ruby -v                      # Print out ruby version for debugging
  #- apt-get update -q && apt-get install nodejs -yqq
  #- bundle install --path vendor # Install dependencies into ./vendor/ruby
  - bundle install

build:
  stage: build
  script:
    - bundle exec jekyll build -d public
  artifacts:
    paths:
    - public
  only:
  - master
  - develop

master-deploy:
  stage: deploy
  before_script:
    # Install ssh client
    - apt-get update
    - apt-get install openssh-client

    # Set up keys
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh
    - echo "$PRIVATE_KEY" > ~/.ssh/id_rsa
    - chmod 600 ~/.ssh/id_rsa

    # Set up known hosts
    - echo "$KNOWN_HOST" > ~/.ssh/known_hosts
    - chmod 644 ~/.ssh/known_hosts

  script:
    # Install rsync
    - apt-get update -qy
    - apt-get install -y rsync  

    # Transfer files
    ...

    # Backup old versions
    ...

  only:
    - master

develop-deploy:
  stage: deploy
  before_script:
    # Install ssh client
    - apt-get update
    - apt-get install openssh-client

    # Set up keys
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh
    - echo "$PRIVATE_KEY" > ~/.ssh/id_rsa
    - chmod 600 ~/.ssh/id_rsa

    # Set up known hosts
    - echo "$KNOWN_HOST" > ~/.ssh/known_hosts
    - chmod 644 ~/.ssh/known_hosts

  script:
    # Install rsync
    - apt-get update -qy
    - apt-get install -y rsync  

    # Transfer files
    ...

    # Backup old version
    ...

  only:
    - develop

一旦我激活缓存build install --path vendor,我就会收到以下错误:

Liquid Exception: Liquid syntax error (line 8): Unknown tag 'when' in vendor/ruby/2.6.0/gems/liquid-4.0.3/lib/liquid/locales/en.yml
jekyll 3.8.6 | Error:  Liquid syntax error (line 8): Unknown tag 'when'

我已经删除了 GitLab 上的缓存(CI/CD->Pipelines->Clear runner cache),但没有成功。任何帮助表示赞赏

标签: jekyllgitlab-cigitlab-ci-runner

解决方案


推荐阅读