简体   繁体   中英

How to specify a newer version of wkhtmltopdf on CircleCI?

I have a spec which tests generation of PDF with PDFKit. It uses the wkhtmltopdf command. I need to use the --javascript-delay option which is available in versions higher than 0.10.0. When my spec runs on CircleCI it fails, because CircleCI uses wkhtltopdf version 0.9.9. Can I specify a higher version of wkhtmltopdf on CircleCI? I specified the newest version of PDFKit in Gemfile, but it doesn't help.

Right now Circle's test environment is Ubuntu 12.04 64-bit. So I went to http://wkhtmltopdf.org/downloads.html and found that the latest stable version of wkhtmltopdf is 0.12.2.1, and copied the download URL into the follow circle.yml configuration:

dependencies:
  pre:
    - sudo apt-get remove wkhtmltopdf
    - sudo apt-get update; sudo apt-get install xfonts-75dpi
    - wget http://downloads.sourceforge.net/wkhtmltopdf/wkhtmltox-0.12.2.1_linux-precise-amd64.deb
    - sudo dpkg -i wkhtmltox-0.12.2.1_linux-precise-amd64.deb

Yes, you can upgrade software on CircleCI build instances. You can either

  • apt-get install the current package, if that's new enough (try it and watch the log to see what version you get) with something like this in circle.yml:

     dependencies: pre: - sudo apt-get update; sudo apt-get install some-package 

or

  • download the source, compile and install it with something like this in circle.yml:

     dependencies: pre: - wget http://example.com/some-package-2.0.0.tar.gz - tar xzf some-package-2.0.0.tar.gz - cd some-package-2.0.0 && make install 

    If you need this solution, see the documentation I linked to above for how to cache the compiled software to speed up builds.

A really, really convenient solution is to simply drop in the gem wkhtmltopdf-heroku . While the name of the gem says heroku, I found that it works just fine in Circle, too. As a bonus, I believe this dependency will be cached between builds without any special instructions to Circle.

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