· ruby asciidoc asciidoctor asciidoctor-pdf gemfile

Running asciidoctor-pdf on TeamCity

I’ve been using asciidoctor-pdf to generate PDF and while I was initially running the tool locally I eventually decided to setup a build on TeamCity.

It was a bit trickier than I expected, mostly because I’m not that familiar with deploying Ruby applications, but I thought I’d capture what I’ve done for future me.

I have the following Gemfile that installs asciidoctor-pdf and its dependencies:

Gemfile

source 'https://rubygems.org'

gem 'prawn'
gem 'addressable'
gem 'prawn-svg'
gem 'prawn-templates'
gem 'asciidoctor-pdf'

I don’t have permissions to install gems globally on the build agents so I’m bundling those up into the vendor directory. It’s been a long time since I worked on a Ruby application so perhaps that’s par for the course.

bundle install --path vendor/
bundle package

On the build agent I’m running the following script:

export PATH="$PATH:/home/teamcity/.gem/ruby/2.3.0/bin"
mkdir $PWD/gems
export GEM_HOME="$PWD/gems"
gem install bundler --user-install --no-rdoc --no-ri && bundle install
./vendor/ruby/2.3.0/bin/asciidoctor-pdf -a allow-uri-read blog.adoc

I override where gems should be installed and then execute the asciidoctor-pdf executable from the vendor directory.

It all seems to work quite nicely but if there’s a better approach that I should be taking so let me know in the comments.

  • LinkedIn
  • Tumblr
  • Reddit
  • Google+
  • Pinterest
  • Pocket