I recently set up TRAVIS CI support for my personal github pages. There are some github and jekyll support pages, that cover the basics. Unfortunately I ran into several build failures and issues not covered there until the builds finally succeeded. The following sections cover the issues and their solutions.
The results can be seen here: https://travis-ci.org/dleidert/dleidert.github.io/builds. I'm planning to add support for different ruby versions. This will probably require different Gemfile variants.
Please note, that I don''t use TRAVIS to deploy the result to github. I'm just testing the build to debug issues. But there is plenty of documentation that covers this issue.
The .travis.yml file below can be re-used without modification as long as github pages live on the master branch. If that is not the case, remove or adjust the branches directive.
branches:
only: masterFurther the file disables notification emails for successful builds.
notifications:
email:
on_success: neverThe package libcurl4-openssl-dev needs to be installed to fix SSL errors like this:
* External link https://[..] failed: response code 0 means something's wrong.
It's possible libcurl couldn't connect to the server or perhaps the request timed out.
Sometimes, making too many requests at once also breaks things.
Either way, the return message (if any) from the server is: SSL connect error
The commented htmlproofer command in the script directive is inspired by this wiki page. Add these options if you like.
The Gemfile below covers the installation of all required Ruby gems including the jekyll plugins my site uses. My first build attempts failed with these errors:
[..]
ERROR: Error installing jekyll:
The last version of rb-inotify (~> 0.9, >= 0.9.7) to support your Ruby & RubyGems was 0.9.10. Try installing it with `gem install rb-inotify -v 0.9.10` and then running the current command again
rb-inotify requires Ruby version >= 2.2. The current ruby version is 2.1.0.
[..]
ERROR: Error installing html-proofer:
The last version of nokogiri (~> 1.9) to support your Ruby & RubyGems was 1.9.1. Try installing it with `gem install nokogiri -v 1.9.1` and then running the current command again
nokogiri requires Ruby version >= 2.3.0. The current ruby version is 2.1.0.
[..]
So this is probably due to using rvm: 2.1 in .travis.yml. To install the compliant versions of rb-inotify and nokogiri, the required versions for these gems were added to the Gemfile.
If the _config.yml file contains a custom exclude: directive like this
exclude:
- ".git*"
- .travis.yml
- README.mdthis directive overwrites the default one and might lead to a build failure with the following error:
$ bundle exec jekyll build
Configuration file: /home/travis/build/dleidert/dleidert.github.io/_config.yml
Source: /home/travis/build/dleidert/dleidert.github.io
Destination: /home/travis/build/dleidert/dleidert.github.io/_site
Incremental build: disabled. Enable with --incremental
Generating...
Error: could not read file /home/travis/build/dleidert/dleidert.github.io/vendor/bundle/ruby/2.1.0/gems/jekyll-3.6.2/lib/site_template/_posts/0000-00-00-welcome-to-jekyll.markdown.erb: Invalid date '<%= Time.now.strftime('%Y-%m-%d %H:%M:%S %z') %>': Document 'vendor/bundle/ruby/2.1.0/gems/jekyll-3.6.2/lib/site_template/_posts/0000-00-00-welcome-to-jekyll.markdown.erb' does not have a valid date in the YAML front matter.
ERROR: YOUR SITE COULD NOT BE BUILT:
------------------------------------
Invalid date '<%= Time.now.strftime('%Y-%m-%d %H:%M:%S %z') %>': Document 'vendor/bundle/ruby/2.1.0/gems/jekyll-3.6.2/lib/site_template/_posts/0000-00-00-welcome-to-jekyll.markdown.erb' does not have a valid date in the YAML front matter.
The command "bundle exec jekyll build" exited with 1.
Due to overwriting the default values, these need to be added to the exclude directive:
exclude:
- Gemfile # default
- Gemfile.lock # default
- node_modules # default
- vendor/ # default is vendor/bundle/, vendor/cache/, vendor/gems/, vendor/ruby/
- ".git*"
- .travis.yml
- README.mdThere is no need to add them, if the _config.yml file does not containan exclude: directive.