我有一个使用 PDFKit 测试 PDF 生成的规范。它使用wkhtmltopdf
命令。我需要使用--javascript-delay
高于 0.10.0 的版本中可用的选项。当我的规范在 CircleCI 上运行时它失败了,因为 CircleCI 使用wkhtltopdf
版本 0.9.9。我可以wkhtmltopdf
在 CircleCI 上指定更高版本吗?我在 Gemfile 中指定了最新版本的 PDFKit,但它没有帮助。
3 回答
目前Circle 的测试环境是 Ubuntu 12.04 64 位。于是我去http://wkhtmltopdf.org/downloads.html发现wkhtmltopdf最新的稳定版是0.12.2.1,把下载地址复制到下面的circle.yml配置中:
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.
一个非常非常方便的解决方案是简单地放入 gem wkhtmltopdf-heroku。虽然 gem 的名称是 heroku,但我发现它在 Circle 中也能正常工作。作为奖励,我相信这种依赖关系将在构建之间缓存,而不需要对 Circle 进行任何特殊说明。