简体   繁体   中英

travis-ci : error during the build (No such file or directory)

I'm having a problem trying to test my build on travis-ci for my jekyll app. One of the plugins generates a json containing informations that my app can reach for a search tool.

The build command works fine on my computer :

bundle exec jekyll build --source octopress

Witch indexes informations into a search.json file in my built directory (_site).

But it fails on travis-ci as on Heroku.

writting search.json to /home/travis/build/alain-andre/mon_site/_site

jekyll 2.5.3 | Error:  No such file or directory - /home/travis/build/alain-andre/mon_site/_site/search.json

Can anyone help ?

OK, I found the solution.

I had to add the search.json into the jekyll site.keep_files .

First to do is to create a Jekyll::StaticFile inside your Jekyll module.

class SearchJson < Jekyll::StaticFile
  def write(dest)
    begin
      super(dest)
    rescue
    end

    true
  end
end

Then, when your file is created, add it to site.static_files like this :

# Keep the file from being cleaned by Jekyll
Jekyll::SearchJson.new(site, site.dest, "/", filename)
site.keep_files << filename

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM