Jekyll 站点地图未在 Gitlab 中构建

Jekyll sitemap not building in Gitlab

在推送到 Gitlab.io 时包含 jekyll-sitemap gem 会使构建失败。当我在本地 运行 jekyll 时,sitemap.xmlmy _site 文件夹中正确生成。

我需要做什么才能让 jekyll-sitemap gem 在 Gitlab 中构建?或者,在推送到 Gitlab 之前,我是否应该以某种方式排除 jekyll-sitemap gem?

Gemfile

source "https://rubygems.org"
ruby '2.0.0'
gem 'jekyll'
gem 'jekyll-sitemap'
gem 'sass'

_config.yml

gems:
- jekyll-sitemap

Gitlab 构建输出

$ gem install jekyll
Successfully installed safe_yaml-1.0.4
Successfully installed rouge-1.10.1
Successfully installed mercenary-0.3.6
Successfully installed liquid-3.0.6
Successfully installed kramdown-1.11.1
Building native extensions.  This could take a while...
Successfully installed ffi-1.9.10
Successfully installed rb-inotify-0.9.7
Successfully installed rb-fsevent-0.9.7
Successfully installed listen-3.0.7
Successfully installed jekyll-watch-1.4.0
Successfully installed sass-3.4.22
Successfully installed jekyll-sass-converter-1.4.0
Successfully installed colorator-0.1
Successfully installed jekyll-3.1.3
14 gems installed
$ jekyll build -d public/
/usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.11.2/lib/bundler/spec_set.rb:94:in `block in materialize': Could not find jekyll-sitemap-0.10.0 in any of the sources (Bundler::GemNotFound)
    from /usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.11.2/lib/bundler/spec_set.rb:87:in `map!'
    from /usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.11.2/lib/bundler/spec_set.rb:87:in `materialize'
    from /usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.11.2/lib/bundler/definition.rb:137:in `specs'
    from /usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.11.2/lib/bundler/definition.rb:182:in `specs_for'
    from /usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.11.2/lib/bundler/definition.rb:171:in `requested_specs'
    from /usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.11.2/lib/bundler/environment.rb:18:in `requested_specs'
    from /usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:13:in `setup'
    from /usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.11.2/lib/bundler.rb:92:in `setup'
    from /usr/local/bundle/gems/jekyll-3.1.3/lib/jekyll/plugin_manager.rb:33:in `require_from_bundler'
    from /usr/local/bundle/gems/jekyll-3.1.3/bin/jekyll:9:in `<top (required)>'
    from /usr/local/bundle/bin/jekyll:22:in `load'
    from /usr/local/bundle/bin/jekyll:22:in `<main>'

我在 运行ning bundle 之后的终端输出:

Using colorator 0.1
Using ffi 1.9.10
Using sass 3.4.22
Using jekyll-sass-converter 1.4.0
Using rb-fsevent 0.9.7
Using rb-inotify 0.9.7
Using listen 3.0.7
Using jekyll-watch 1.4.0
Using kramdown 1.11.1
Using liquid 3.0.6
Using mercenary 0.3.6
Using rouge 1.10.1
Using safe_yaml 1.0.4
Using jekyll 3.1.3
Using jekyll-sitemap 0.10.0
Using bundler 1.10.6
Bundle complete! 3 Gemfile dependencies, 16 gems now installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.

已编辑答案 :

事实上,答案就在您的 .gitlab-ci.yml 中。我猜这个文件包含类似 :

...
pages:
  stage: deploy
  script:
    - gem install jekyll
    - jekyll build -d public
...

如果你想 运行 gitlab-ci 这种方式(没有捆绑器),这个文件必须包含类似的东西:

...
pages:
  stage: deploy
  script:
    - gem install jekyll
    - gem install jekyll-sitemap
    - jekyll build -d public
...

这里是my test repository .gitlab-ci.yml file.

gitlab-ci documentation

旧答案:你为什么不使用bundle exec jekyll build -d public/