├── .gitignore ├── README.md └── config.xml /.gitignore: -------------------------------------------------------------------------------- 1 | nextBuildNumber 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## What is it? 2 | This is a template to be used in Jenkins CI in order to build a Ruby On Rails project 3 | 4 | ## Required hudson plugins 5 | * [Ruby metrics plugin](http://wiki.jenkins-ci.org/display/JENKINS/Ruby+Metrics+Plugin) 6 | * [Rake plugin](Jenkins Rake plugin) 7 | * [Html Publisher](http://wiki.hudson-ci.org/display/HUDSON/HTML+Publisher+Plugin) 8 | 9 | ## Required Ruby gems 10 | * [ci\_reporter](https://github.com/nicksieger/ci_reporter) 11 | * [metrical](https://github.com/iain/metrical) 12 | 13 | ## Usage 14 | 15 | After you've installed require gems in your project test the following commands are working in your environment 16 | 17 | rake db:migrate db:test:prepare 18 | rake ci:setup:rspec spec:rcov 19 | rake CUCUMBER_OPTS='--format html --out features/reports/features.html' cucumber 20 | metrical 21 | 22 | You should edit your `Rakefile` to make some of them working by adding the following lines 23 | 24 | # used to generate ci reports, see ci_reporter documentation 25 | require 'ci/reporter/rake/rspec' 26 | 27 | Finally you should add metrical configuration in `.metric` file in your project, this is the mine 28 | 29 | # used to generate metrics, see metric_fu documentation 30 | MetricFu::Configuration.run do |config| 31 | config.metrics = [:churn, :flog, :flay, :reek, :roodi, :hotspots, :rails_best_practices] 32 | config.metrics << :saikuro unless RUBY_VERSION == '1.9.2' 33 | config.graphs = [:flog, :flay, :reek, :roodi, :rails_best_practices] 34 | end 35 | 36 | I excluded rcov from `metric_fu` configuration because coverage task is included in Ruby Metrics Plugin. 37 | 38 | Then in order to configure Jenkins: 39 | 40 | 1. Install required Jenkins plugins using the plugin manager 41 | 2. Make [rvm](https://rvm.beginrescueend.com/) available to the Jenkins user 42 | 3. Install at least one Ruby for the jenkins user and set it to default with `rvm use --default`, where `` is the version you've installed. 43 | 3. Install `metrical` gem for the jenkins user (`rvm use default && gem install metrical`) 44 | 2. Install this template in Jenkins by `cd $JENKINS_HOME/jobs && git clone git://github.com/fabn/rails-jenkins-template.git rails-template` 45 | 3. Restart Jenkins to load the new job template 46 | 3. Click on "New Job" 47 | 4. Enter a "Job Name" 48 | 5. Select "Copy existing job" and enter "rails-template" into the "Copy from" field. 49 | 6. Click "OK" 50 | 7. Disable the "Disable Build" option 51 | 8. Fill in your "Source Code Management" information 52 | 9. Edit project options as your needs (i.e. disabling some steps or reports) 53 | 9. Click "Save" 54 | 55 | ## Thanks to 56 | 57 | * Sebastian Bergmann for the idea [http://jenkins-php.org/](http://jenkins-php.org) -------------------------------------------------------------------------------- /config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | false 6 | 7 | 8 | true 9 | true 10 | false 11 | false 12 | 13 | false 14 | 15 | 16 | if [ -f $WORKSPACE/.rvmrc ]; then source $WORKSPACE/.rvmrc; else rvm use default; fi; bundle install; mkdir -p features/reports 17 | 18 | 19 | (Default) 20 | 21 | 22 | 23 | db:migrate db:test:prepare 24 | false 25 | 26 | 27 | (Default) 28 | 29 | 30 | 31 | ci:setup:rspec spec:rcov 32 | false 33 | 34 | 35 | (Default) 36 | 37 | 38 | 39 | CUCUMBER_OPTS="--format html --out features/reports/features.html" cucumber 40 | false 41 | 42 | 43 | metrical 44 | 45 | 46 | 47 | 48 | spec/reports/*.xml 49 | false 50 | 51 | 52 | 53 | 54 | 55 | Metrics Fu 56 | tmp/metric_fu/output 57 | index.html 58 | true 59 | htmlpublisher-wrapper.html 60 | 61 | 62 | Cucumber Features 63 | features/reports 64 | features.html 65 | true 66 | htmlpublisher-wrapper.html 67 | 68 | 69 | 70 | 71 | coverage 72 | 73 | 74 | TOTAL_COVERAGE 75 | 80 76 | 0 77 | 0 78 | 79 | 80 | CODE_COVERAGE 81 | 80 82 | 0 83 | 0 84 | 85 | 86 | 87 | 88 | 89 | (Default) 90 | 91 | stats 92 | true 93 | 94 | (Default) 95 | 96 | stats 97 | 98 | 99 | 100 | (Default) 101 | 102 | notes 103 | true 104 | 105 | (Default) 106 | 107 | notes 108 | 109 | 110 | 111 | --------------------------------------------------------------------------------