When I first read about BDD documentation cucumber-yard here, I fell in love. I then decided to try it out and write my experience in setting it up. That worked great, however I always thought that cucumber-yard would add even more value if I could automate the process of generating BDD documents on fly and host it somewhere. The search began and I decided to setup a Jenkins job which can poll for changes to my git repository, run cucumber yard and publish documents automagically. That way team can refer to an always up-to-date living, runnable BDD documentation.
So I decided to play with Jenkins. Any change to automation Github repo, will trigger a job that will generate cucumber-yard docs. My initial attempts to run ruby commands in shell failed because Jenkins runs all of its jobs with user “jenkins” and the ruby version for “jenkins” user was not compatible with cucumber-yard. After further research I came across RVM plugin for Jenkins which I thought would solve the ruby version issue. I further decided to use Rake plugin to invoke rake tasks and HTML Publisher plugin to publish cucumber yard docs on Jenkins. So to summarize, here is my Jenkins setup looked like,
1. RVM plugin – to select suitable ruby version for cucumber-yard
2. Rake Plugin- to invoke rake tasks
3. Publish HTML Reports – to publish cucumber yard docs on jenkins
This seemed straightforward to setup, however I stumbled upon a newer road block. I wasn’t able to use RVM plugin properly since “jenkins” user did not have enough privileges to install ruby in System directory. I got below errors at RVM step
[workspace] $ bash -c " source ~/.rvm/scripts/rvm && rvm use --install --create 2.0.0 && export > rvm.env"
ruby-2.0.0-p451 is not installed - installing.
Searching for binary rubies, this might take some time.
Found remote file https://rvm.io/binaries/osx/10.9/x86_64/ruby-2.0.0-p451.tar.bz2
Checking requirements for osx.
ERROR: '/usr/local/bin' is not writable - it is required for Homebrew, try 'brew doctor' to fix it!
I solved this by giving “jenkins” user special permissions like
sudo chown –R jenkins:admin /usr/local/bin
Also make sure to configure Yard for your jenkins user like,
$ mkdir ~/.yard (create .yard in your home directory)
$ yard config load_plugins true
$ yardoc 'src/test/resources/features/*.feature'
After this, RVM plugin was able to install and switch to provided ruby version. After this was resolved, the rest of it was fairly straightforward and it worked great. Here are some sample screenshots of my Jenkins configuration to generate cucumber yard documents.
This entire setup is working great for my team and I hope this post helps you setup cucumber yard on Jenkins.
To goto cucumber yard reports, navigate to